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


PHP GroupInterface::addProduct方法代码示例

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


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

示例1: ProductValue

 function it_updates_a_variant_group($attributeRepository, $groupTypeRepository, $productBuilder, $pqbFactory, GroupInterface $variantGroup, AttributeInterface $attribute, GroupTypeInterface $type, GroupTranslation $translatable, ProductInterface $product, ProductInterface $removedProduct, ProductInterface $addedProduct, ProductTemplateInterface $productTemplate, ProductQueryBuilderInterface $pqb)
 {
     $groupTypeRepository->findOneByIdentifier('VARIANT')->willReturn($type);
     $attributeRepository->findOneByIdentifier('main_color')->willReturn($attribute);
     $attributeRepository->findOneByIdentifier('secondary_color')->willReturn($attribute);
     $pqbFactory->create()->willReturn($pqb);
     $pqb->addFilter('id', 'IN', [2])->shouldBeCalled();
     $pqb->execute()->willReturn([$addedProduct]);
     $variantGroup->getTranslation()->willReturn($translatable);
     $translatable->setLabel('T-shirt super beau')->shouldBeCalled();
     $variantGroup->setCode('mycode')->shouldBeCalled();
     $variantGroup->setLocale('fr_FR')->shouldBeCalled();
     $variantGroup->setType($type)->shouldBeCalled();
     $variantGroup->getId()->willReturn(null);
     $variantGroup->addAxisAttribute(Argument::any())->shouldBeCalled();
     $variantGroup->removeProduct($removedProduct)->shouldBeCalled();
     $variantGroup->addProduct($addedProduct)->shouldBeCalled();
     $variantGroup->getProducts()->willReturn([$removedProduct]);
     $productTemplate->getValuesData()->willReturn([]);
     $productTemplate->setValues(Argument::any())->shouldBeCalled();
     $productTemplate->setValuesData(['main_color' => [['locale' => null, 'scope' => null, 'data' => 'white']]])->shouldBeCalled();
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $variantGroup->setProductTemplate($productTemplate)->shouldBeCalled();
     $productValue = new ProductValue();
     $identifierValue = new ProductValue();
     $productBuilder->createProduct()->willReturn($product);
     $product->getValues()->willReturn(new ArrayCollection([$productValue, $identifierValue]));
     $product->getIdentifier()->willReturn($identifierValue);
     $values = ['code' => 'mycode', 'axis' => ['main_color', 'secondary_color'], 'type' => 'VARIANT', 'labels' => ['fr_FR' => 'T-shirt super beau'], 'values' => ['main_color' => [['locale' => null, 'scope' => null, 'data' => 'white']]], 'products' => [2]];
     $this->update($variantGroup, $values, []);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:31,代码来源:VariantGroupUpdaterSpec.php

示例2: bindProducts

 /**
  * Bind products
  *
  * @param GroupInterface $group
  * @param array          $appendProducts
  * @param array          $removeProducts
  */
 protected function bindProducts(GroupInterface $group, array $appendProducts, array $removeProducts)
 {
     foreach ($appendProducts as $product) {
         $group->addProduct($product);
     }
     foreach ($removeProducts as $product) {
         $group->removeProduct($product);
     }
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:16,代码来源:BindGroupProductsSubscriber.php

示例3:

 function it_updates_a_group($groupTypeRepository, $attributeRepository, $pqbFactory, GroupInterface $group, GroupTypeInterface $type, GroupTranslation $translatable, AttributeInterface $attributeColor, AttributeInterface $attributeSize, ProductInterface $removedProduct, ProductInterface $addedProduct, ProductQueryBuilderInterface $pqb)
 {
     $groupTypeRepository->findOneByIdentifier('RELATED')->willReturn($type);
     $attributeRepository->findOneByIdentifier('color')->willReturn($attributeColor);
     $attributeRepository->findOneByIdentifier('size')->willReturn($attributeSize);
     $pqbFactory->create()->willReturn($pqb);
     $pqb->addFilter('id', 'IN', [2])->shouldBeCalled();
     $pqb->execute()->willReturn([$addedProduct]);
     $group->getTranslation()->willReturn($translatable);
     $translatable->setLabel('T-shirt super beau')->shouldBeCalled();
     $group->setCode('mycode')->shouldBeCalled();
     $group->setLocale('fr_FR')->shouldBeCalled();
     $group->setType($type)->shouldBeCalled();
     $group->setAxisAttributes([$attributeColor, $attributeSize])->shouldBeCalled();
     $group->getId()->willReturn(null);
     $group->removeProduct($removedProduct)->shouldBeCalled();
     $group->addProduct($addedProduct)->shouldBeCalled();
     $group->getProducts()->willReturn([$removedProduct]);
     $values = ['code' => 'mycode', 'type' => 'RELATED', 'labels' => ['fr_FR' => 'T-shirt super beau'], 'axis' => ['color', 'size'], 'products' => [2]];
     $this->update($group, $values, []);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:GroupUpdaterSpec.php

示例4: setProducts

 /**
  * @param GroupInterface $group
  * @param array          $labels
  */
 protected function setProducts(GroupInterface $group, array $productIds)
 {
     foreach ($group->getProducts() as $product) {
         $group->removeProduct($product);
     }
     if (empty($productIds)) {
         return;
     }
     $pqb = $this->productQueryBuilderFactory->create();
     $pqb->addFilter('id', 'IN', $productIds);
     $products = $pqb->execute();
     foreach ($products as $product) {
         $group->addProduct($product);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:GroupUpdater.php

示例5:

 function it_is_not_attribute_removable_with_group_containing_attribute(AttributeInterface $attribute, GroupInterface $group, GroupTypeInterface $groupType, ArrayCollection $groupAttributes)
 {
     $groupType->isVariant()->willReturn(true);
     $groupAttributes->contains($attribute)->willReturn(true);
     $group->getType()->willReturn($groupType);
     $group->getAxisAttributes()->willReturn($groupAttributes);
     $group->addProduct($this)->willReturn($this);
     $this->addGroup($group);
     $this->isAttributeRemovable($attribute)->shouldReturn(false);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:10,代码来源:ProductSpec.php


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