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


PHP ProductInterface::getGroupCodes方法代码示例

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


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

 /**
  * {@inheritdoc}
  *
  * @param ProductInterface $object
  */
 public function normalize($object, $format = null, array $context = [])
 {
     $context = $this->resolveContext($context);
     $results = $this->serializer->normalize($object->getIdentifier(), $format, $context);
     $results[self::FIELD_FAMILY] = $this->normalizeFamily($object->getFamily());
     $results[self::FIELD_GROUPS] = $this->normalizeGroups($object->getGroupCodes());
     $results[self::FIELD_CATEGORY] = $this->normalizeCategories($object->getCategoryCodes());
     $results = array_merge($results, $this->normalizeAssociations($object->getAssociations()));
     $results = array_replace($results, $this->normalizeValues($object, $format, $context));
     $results[self::FIELD_ENABLED] = (int) $object->isEnabled();
     return $results;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:ProductNormalizer.php

示例3: 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

示例4: 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

示例5:

 function it_normalizes_product_with_price($filter, ProductInterface $product, AttributeInterface $priceAttribute, ProductValueInterface $price, Collection $prices, Collection $values, ProductPriceInterface $productPrice, FamilyInterface $family, SerializerInterface $serializer)
 {
     $family->getCode()->willReturn('shoes');
     $priceAttribute->getCode()->willReturn('price');
     $priceAttribute->getAttributeType()->willReturn('pim_catalog_price_collection');
     $priceAttribute->isLocalizable()->willReturn(false);
     $priceAttribute->isScopable()->willReturn(false);
     $price->getAttribute()->willReturn($priceAttribute);
     $price->getData()->willReturn(null);
     $productPrice->getData()->willReturn("356.00");
     $productPrice->getCurrency()->willReturn("EUR");
     $prices->add($productPrice);
     $price->getPrices()->willReturn($prices);
     $product->getIdentifier()->willReturn($price);
     $product->getFamily()->willReturn($family);
     $product->isEnabled()->willReturn(true);
     $product->getGroupCodes()->willReturn(['group1', 'group2', 'variant_group_1']);
     $product->getCategoryCodes()->willReturn(['nice shoes', 'converse']);
     $product->getAssociations()->willReturn([]);
     $values->add($price);
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.flat', Argument::cetera())->willReturn([$price]);
     $serializer->normalize($price, 'flat', Argument::any())->willReturn(['price-EUR' => '356.00']);
     $this->normalize($product, 'flat', ['price-EUR' => ''])->shouldReturn(['price-EUR' => '356.00', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes,converse', 'enabled' => 1]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:ProductNormalizerSpec.php

示例6: 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::getGroupCodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。