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


PHP ProductInterface::getVariantGroup方法代码示例

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


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

示例1:

 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:noglitchyo,项目名称:pim-community-dev,代码行数:14,代码来源:HasVariantAxesValidatorSpec.php

示例2: 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:noglitchyo,项目名称:pim-community-dev,代码行数:23,代码来源:UniqueVariantAxisValidator.php

示例3: getGroups

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

示例4: doPerform

 /**
  * {@inheritdoc}
  */
 protected function doPerform(ProductInterface $product)
 {
     if (null === $product->getVariantGroup()) {
         $this->group->addProduct($product);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:9,代码来源:AddToVariantGroup.php

示例5:

 function it_generates_warning_message_if_variant_group_without_common_attribute_is_skipped($groupRepository, $productMassActionRepo, CustomGroupInterface $shoes, CustomGroupInterface $glasses, ProductInterface $product1, ProductInterface $product2)
 {
     $product1->getVariantGroup()->willReturn(null);
     $product2->getVariantGroup()->willReturn(null);
     $this->setObjectsToMassEdit([$product1, $product2]);
     $product1->getId()->willReturn(1);
     $product2->getId()->willReturn(2);
     $productMassActionRepo->findCommonAttributeIds([1, 2])->willReturn([42]);
     $groupRepository->getVariantGroupsByAttributeIds([42])->willReturn([$glasses]);
     $glasses->getId()->willReturn(100);
     $groupRepository->getVariantGroupsByIds([100], false)->willReturn([$shoes]);
     $shoes->getLabel()->willReturn('Shoes');
     $shoes->getCode()->willReturn('shoes');
     $groupRepository->countVariantGroups()->willReturn(2);
     $this->getFormOptions();
     $this->getWarningMessages()->shouldReturn([['key' => 'pim_enrich.mass_edit_action.add-to-variant-group.some_variant_groups_are_skipped', 'options' => ['%groups%' => 'Shoes [shoes]']]]);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:AddToVariantGroupSpec.php

示例6: 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:VinceBLOT,项目名称:pim-community-dev,代码行数:23,代码来源:ProductUpdater.php

示例7: 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:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:ProductTransformer.php

示例8:

 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:noglitchyo,项目名称:pim-community-dev,代码行数:24,代码来源:UniqueVariantAxisValidatorSpec.php


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