当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductInterface::getVariantGroup方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::getVariantGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getVariantGroup方法的具体用法?PHP ProductInterface::getVariantGroup怎么用?PHP ProductInterface::getVariantGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\ProductInterface的用法示例。


在下文中一共展示了ProductInterface::getVariantGroup方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: use

 function it_normalizes_the_properties_of_the_product($filter, $serializer, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value, FamilyInterface $family, ArrayCollection $values, \ArrayIterator $iterator, ProductValueInterface $identifier)
 {
     $values->getIterator()->willReturn($iterator);
     $family->getCode()->willReturn('my_family');
     $product->getFamily()->willReturn($family);
     $product->getGroupCodes()->willReturn([]);
     $product->getVariantGroup()->willReturn(null);
     $product->getCategoryCodes()->willReturn([]);
     $product->isEnabled()->willReturn(true);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('name');
     $product->getIdentifier()->willReturn($identifier);
     $identifier->getData()->willReturn('my_code');
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.structured', Argument::type('array'))->shouldBeCalled()->willReturn($values);
     $iterator->rewind()->willReturn(null);
     $valueCount = 1;
     $iterator->valid()->will(function () use(&$valueCount) {
         return $valueCount-- > 0;
     });
     $iterator->current()->willReturn($value);
     $iterator->next()->willReturn(null);
     $context = ['filter_types' => ['pim.transform.product_value.structured']];
     $serializer->normalize($value, 'standard', $context)->willReturn(['locale' => null, 'scope' => null, 'value' => 'foo']);
     $created = new \DateTime('2010-06-23');
     $product->getCreated()->willReturn($created);
     $serializer->normalize($created, 'standard')->willReturn('2010-06-23T00:00:00+01:00');
     $updated = new \DateTime('2010-06-23 23:00:00');
     $product->getUpdated()->willReturn($updated);
     $serializer->normalize($updated, 'standard')->willReturn('2010-06-23T23:00:00+01:00');
     $this->normalize($product, 'standard', $context)->shouldReturn(['identifier' => 'my_code', 'family' => 'my_family', 'groups' => [], 'variant_group' => null, 'categories' => [], 'enabled' => true, 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]], 'created' => '2010-06-23T00:00:00+01:00', 'updated' => '2010-06-23T23:00:00+01:00']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:32,代码来源:PropertiesNormalizerSpec.php

示例2:

 function it_adds_a_violation_when_validates_a_product_with_missing_value_for_an_axe_of_its_variant_group($context, ProductInterface $product, GroupInterface $tShirtVariantGroup, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeValue, ProductValueInterface $identifierValue, HasVariantAxes $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $tShirtVariantGroup->getCode()->willReturn('tshirt');
     $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
     $sizeAttribute->getCode()->willReturn('size');
     $colorAttribute->getCode()->willReturn('color');
     $product->getIdentifier()->willReturn($identifierValue);
     $product->getVariantGroup()->willReturn($tShirtVariantGroup);
     $product->getValue('size')->willReturn($sizeValue);
     $product->getValue('color')->willReturn(null);
     $sizeValue->getData()->willReturn('XL');
     $context->buildViolation('The product "%product%" is in the variant group "%variant%" but it misses the following axes: %axes%.', ['%product%' => $identifierValue, '%variant%' => 'tshirt', '%axes%' => 'color'])->shouldBeCalled()->willReturn($violation);
     $this->validate($product, $constraint);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:HasVariantAxesValidatorSpec.php

示例3: validateProduct

 /**
  * Validate product
  *
  * @param ProductInterface $product
  * @param Constraint       $constraint
  */
 protected function validateProduct(ProductInterface $product, Constraint $constraint)
 {
     $group = $product->getVariantGroup();
     if (null === $group) {
         return;
     }
     $criteria = $this->prepareQueryCriterias($group, $product, $constraint);
     $matches = $this->getMatchingProducts($group, $product, $criteria);
     if (count($matches) !== 0) {
         $values = [];
         foreach ($criteria as $item) {
             $data = $item['attribute']->isBackendTypeReferenceData() ? $item['referenceData']['data'] : $item['option'];
             $values[] = sprintf('%s: %s', $item['attribute']->getCode(), (string) $data);
         }
         $this->addExistingCombinationViolation($constraint, $group->getLabel(), implode(', ', $values));
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:UniqueVariantAxisValidator.php

示例4: use

 function it_normalizes_the_properties_of_the_product(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value, ArrayCollection $values, \ArrayIterator $iterator, $filter, $normalizer)
 {
     $values->getIterator()->willReturn($iterator);
     $product->getFamily()->willReturn(null);
     $product->getGroupCodes()->willReturn([]);
     $product->getVariantGroup()->willReturn(null);
     $product->getCategoryCodes()->willReturn([]);
     $product->isEnabled()->willReturn(true);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('name');
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.structured', Argument::type('array'))->shouldBeCalled()->willReturn($values);
     $iterator->rewind()->willReturn(null);
     $valueCount = 1;
     $iterator->valid()->will(function () use(&$valueCount) {
         return $valueCount-- > 0;
     });
     $iterator->current()->willReturn($value);
     $iterator->next()->willReturn(null);
     $normalizer->normalize($values, 'json', Argument::any())->willReturn(['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]]);
     $this->normalize($product, 'json')->shouldReturn(['family' => null, 'groups' => [], 'variant_group' => null, 'categories' => [], 'enabled' => true, 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]]]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:ProductPropertiesNormalizerSpec.php

示例5: setProductValuesFromVariantGroup

 /**
  * @param ProductInterface $product
  */
 protected function setProductValuesFromVariantGroup(ProductInterface $product)
 {
     $variantGroup = $product->getVariantGroup();
     if ($variantGroup !== null && $variantGroup->getProductTemplate() !== null) {
         $template = $variantGroup->getProductTemplate();
         $this->templateUpdater->update($template, [$product]);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:ProductTransformer.php

示例6:

 function it_adds_a_violation_when_validating_product_in_groups_with_non_unique_combination_of_axis_attributes($context, $productRepository, GroupInterface $tShirtVariantGroup, ProductInterface $redTShirtProduct, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $colorProductValue, ProductInterface $redTShirtProduct2, UniqueVariantAxis $uniqueVariantAxisConstraint, ConstraintViolationBuilderInterface $violation)
 {
     $redTShirtProduct->getVariantGroup()->willReturn($tShirtVariantGroup);
     $tShirtVariantGroup->getId()->willReturn(1);
     $tShirtVariantGroup->getLabel()->willReturn('TShirts');
     $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
     $sizeAttribute->getCode()->willReturn('size');
     $sizeAttribute->isBackendTypeReferenceData()->willReturn(true);
     $sizeAttribute->getReferenceDataName()->willReturn('ref_size');
     $colorAttribute->getCode()->willReturn('color');
     $colorAttribute->isBackendTypeReferenceData()->willReturn(true);
     $colorAttribute->getReferenceDataName()->willReturn('ref_color');
     $redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
     $redTShirtProduct->getValue('color')->willReturn($colorProductValue);
     $redTShirtProduct->getId()->willReturn(1);
     $sizeProductValue->getData()->willReturn('XL');
     $sizeProductValue->getOption()->willReturn(null);
     $colorProductValue->getData()->willReturn('Red');
     $colorProductValue->getOption()->willReturn(null);
     $criteria = [['attribute' => $sizeAttribute, 'referenceData' => ['name' => 'ref_size', 'data' => 'XL']], ['attribute' => $colorAttribute, 'referenceData' => ['name' => 'ref_color', 'data' => 'Red']]];
     $productRepository->findAllForVariantGroup($tShirtVariantGroup, $criteria)->shouldBeCalled()->willReturn([$redTShirtProduct2]);
     $context->buildViolation('Group "%variant group%" already contains another product with values "%values%"', ['%variant group%' => 'TShirts', '%values%' => 'size: XL, color: Red'])->shouldBeCalled()->willReturn($violation);
     $this->validate($redTShirtProduct, $uniqueVariantAxisConstraint);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:24,代码来源:UniqueVariantAxisValidatorSpec.php

示例7: updateProductVariantValues

 /**
  * Updates product with its variant group values to ensure that values coming from variant group are always
  * applied after the product values (if a product value is updated and should come from variant group)
  *
  * @param ProductInterface $product
  * @param array            $data
  */
 protected function updateProductVariantValues(ProductInterface $product, array $data)
 {
     $variantGroup = $product->getVariantGroup();
     $shouldEraseData = false;
     if (null !== $variantGroup && null !== $variantGroup->getProductTemplate()) {
         $template = $variantGroup->getProductTemplate();
         foreach (array_keys($data) as $field) {
             if ($template->hasValueForAttributeCode($field) || null === $product->getValue($field)) {
                 $shouldEraseData = true;
             }
         }
         if ($shouldEraseData) {
             $this->templateUpdater->update($template, [$product]);
         }
     }
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:23,代码来源:ProductUpdater.php

示例8: getGroups

 /**
  * @param ProductInterface $product
  *
  * @return array
  */
 protected function getGroups(ProductInterface $product)
 {
     $groups = [];
     if ($product->getGroupCodes()) {
         $groups = $product->getGroupCodes();
         if ($product->getVariantGroup()) {
             $variantGroup = $product->getVariantGroup()->getCode();
             $groups = array_diff($groups, [$variantGroup]);
         }
     }
     return $groups;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:ProductNormalizer.php

示例9: normalizeGroups

 /**
  * @param ProductInterface $product
  *
  * @return array
  */
 private function normalizeGroups(ProductInterface $product)
 {
     $groupCodes = [];
     if (count($product->getGroupCodes()) > 0) {
         $groupCodes = $product->getGroupCodes();
         if (null !== $product->getVariantGroup()) {
             $variantGroupCode = $product->getVariantGroup()->getCode();
             $groupCodes = array_diff($groupCodes, [$variantGroupCode]);
         }
     }
     return $groupCodes;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:PropertiesNormalizer.php


注:本文中的Pim\Component\Catalog\Model\ProductInterface::getVariantGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。