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


PHP GroupInterface::getProducts方法代码示例

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


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

示例1: validateVariantGroup

 /**
  * Validate variant group
  *
  * @param GroupInterface $variantGroup
  * @param Constraint     $constraint
  */
 protected function validateVariantGroup(GroupInterface $variantGroup, Constraint $constraint)
 {
     $existingCombinations = array();
     $products = $variantGroup->getProducts();
     if (null === $products) {
         $products = $this->getMatchingProducts($variantGroup);
     }
     foreach ($products as $product) {
         $values = array();
         foreach ($variantGroup->getAxisAttributes() as $attribute) {
             $code = $attribute->getCode();
             $option = $product->getValue($code) ? (string) $product->getValue($code)->getOption() : null;
             if (null === $option) {
                 $this->addEmptyAxisViolation($constraint, $variantGroup->getLabel(), $product->getIdentifier()->getVarchar(), $attribute->getCode());
             }
             $values[] = sprintf('%s: %s', $code, $option);
         }
         $combination = implode(', ', $values);
         if (in_array($combination, $existingCombinations)) {
             $this->addExistingCombinationViolation($constraint, $variantGroup->getLabel(), $combination);
         } else {
             $existingCombinations[] = $combination;
         }
     }
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:31,代码来源:UniqueVariantAxisValidator.php

示例2:

 function it_does_not_copy_values_to_products_when_template_is_empty(GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, Collection $productCollection, ProductInterface $productOne, ProductInterface $productTwo, $productTplApplier, $stepExecution)
 {
     $variantGroup->getId()->willReturn(42);
     $stepExecution->incrementSummaryInfo('update')->shouldBeCalled();
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $productTemplate->getValuesData()->willReturn([]);
     $variantGroup->getProducts()->willReturn($productCollection);
     $productCollection->isEmpty()->willReturn(false);
     $productCollection->toArray()->willReturn([$productOne, $productTwo]);
     $productCollection->count()->willReturn(2);
     $productTplApplier->apply($productTemplate, [$productOne, $productTwo])->shouldNotBeCalled();
     $this->write([$variantGroup]);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:13,代码来源:VariantGroupWriterSpec.php

示例3:

 function it_adds_violation_when_validating_group_containing_products_with_non_unique_combination_of_axis_attributes($context, GroupInterface $tShirtVariantGroup, GroupTypeInterface $tShirtGroupType, ProductInterface $redTShirtProduct, ProductInterface $redTShirtProduct2, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeProductValue, ProductValueInterface $colorProductValue, UniqueVariantAxis $uniqueVariantAxisConstraint, ConstraintViolationBuilderInterface $violation)
 {
     $tShirtGroupType->isVariant()->willReturn(true);
     $tShirtVariantGroup->getType()->willReturn($tShirtGroupType);
     $tShirtVariantGroup->getProducts()->willReturn([$redTShirtProduct, $redTShirtProduct2]);
     $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);
     $sizeAttribute->getCode()->willReturn('size');
     $colorAttribute->getCode()->willReturn('color');
     $sizeProductValue->getOption()->willReturn('XL');
     $colorProductValue->getOption()->willReturn('Red');
     $redTShirtProduct->getValue('size')->willReturn($sizeProductValue);
     $redTShirtProduct->getValue('color')->willReturn($colorProductValue);
     $redTShirtProduct2->getValue('size')->willReturn($sizeProductValue);
     $redTShirtProduct2->getValue('color')->willReturn($colorProductValue);
     $tShirtVariantGroup->getLabel()->willReturn('Groupe TShirt');
     $context->buildViolation('Group "%variant group%" already contains another product with values "%values%"', ['%variant group%' => 'Groupe TShirt', '%values%' => 'size: XL, color: Red'])->shouldBeCalled()->willReturn($violation);
     $this->validate($tShirtVariantGroup, $uniqueVariantAxisConstraint);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:18,代码来源:UniqueVariantAxisValidatorSpec.php

示例4: copyValuesToProducts

 /**
  * Copy variant group values to products
  *
  * @param GroupInterface $variantGroup
  */
 protected function copyValuesToProducts(GroupInterface $variantGroup)
 {
     $template = $variantGroup->getProductTemplate();
     $products = $variantGroup->getProducts();
     if ($template && count($template->getValuesData()) > 0 && count($products) > 0) {
         $skippedMessages = $this->productTplApplier->apply($template, $products->toArray());
         $nbSkipped = count($skippedMessages);
         $nbUpdated = count($products) - $nbSkipped;
         $this->incrementUpdatedProductsCount($nbUpdated);
         if ($nbSkipped > 0) {
             $this->incrementSkippedProductsCount($nbSkipped, $skippedMessages);
         }
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:19,代码来源:VariantGroupWriter.php

示例5: copyVariantGroupValues

 /**
  * Copy the variant group values on any products belonging in the variant group
  *
  * @param GroupInterface $group
  */
 protected function copyVariantGroupValues(GroupInterface $group)
 {
     $template = $group->getProductTemplate();
     $products = $group->getProducts()->toArray();
     $this->productTplApplier->apply($template, $products);
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:11,代码来源:GroupSaver.php

示例6:

 function it_marks_products_as_updated_when_a_group_is_removed_or_updated(EntityManager $em, ProductInterface $foo, ProductInterface $bar, GroupInterface $group)
 {
     $group->getProducts()->willReturn([$foo, $bar]);
     $this->guessUpdates($em, $group, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([$foo, $bar]);
     $this->guessUpdates($em, $group, UpdateGuesserInterface::ACTION_DELETE)->shouldReturn([$foo, $bar]);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:6,代码来源:ContainsProductsUpdateGuesserSpec.php


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