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


PHP ProductInterface::getFamily方法代码示例

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


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

示例1: shouldBeSetInProduct

 /**
  * As boolean attribute does not support "null" value (only true/false),
  * there are some problems to make out what should really be added to the product (specially with optional attributes)
  * What we add in product:
  * | old value | new value | attribute is in family | should be added in product |
  * | null      | false     | yes                    | no                         |
  * | null      | false     | no                     | yes                        |
  *
  * This method should be removed when boolean attribute will be rework to support 3 states: true/false/null
  *
  * @deprecated will be removed in 1.7
  *
  * @param ProductInterface   $product    product to update
  * @param AttributeInterface $attribute  attribute
  * @param mixed              $data       new value
  *
  * @return bool
  */
 private function shouldBeSetInProduct(ProductInterface $product, AttributeInterface $attribute, $data)
 {
     $family = $product->getFamily();
     if (null !== $family && in_array($attribute->getCode(), $product->getFamily()->getAttributeCodes()) && false === $data) {
         return false;
     }
     return true;
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:26,代码来源:BooleanAttributeSetter.php

示例2:

 function it_provide_product_completeness_if_family_is_not_defined(ProductInterface $product, ChannelInterface $mobile, LocaleInterface $en)
 {
     $product->getFamily()->willReturn(null);
     $en->getCode()->willReturn('en_US');
     $mobile->getCode()->willReturn('mobile');
     $this->getProductCompleteness($product, [$mobile], [$en], 'en_US')->shouldReturn([['channels' => [['completeness' => null, 'missing' => []]], 'stats' => ['total' => 0, 'complete' => 0], 'locale' => '']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:CompletenessManagerSpec.php

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

示例4:

 function it_adds_missing_product_values_from_family_on_new_product($valuesResolver, FamilyInterface $family, ProductInterface $product, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, ProductValueInterface $skuValue)
 {
     $sku->getCode()->willReturn('sku');
     $sku->getAttributeType()->willReturn('pim_catalog_identifier');
     $sku->isLocalizable()->willReturn(false);
     $sku->isScopable()->willReturn(false);
     $name->getCode()->willReturn('name');
     $name->getAttributeType()->willReturn('pim_catalog_text');
     $name->isLocalizable()->willReturn(true);
     $name->isScopable()->willReturn(false);
     $desc->getCode()->willReturn('description');
     $desc->getAttributeType()->willReturn('pim_catalog_text');
     $desc->isLocalizable()->willReturn(true);
     $desc->isScopable()->willReturn(true);
     // get expected attributes
     $product->getAttributes()->willReturn([$sku]);
     $family->getAttributes()->willReturn([$sku, $name, $desc]);
     $product->getFamily()->willReturn($family);
     // get eligible values
     $valuesResolver->resolveEligibleValues(['sku' => $sku, 'name' => $name, 'description' => $desc], null, null)->willReturn([['attribute' => 'sku', 'type' => 'pim_catalog_identifier', 'locale' => null, 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => null], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'print'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'print']]);
     // get existing values
     $skuValue->getAttribute()->willReturn($sku);
     $skuValue->getLocale()->willReturn(null);
     $skuValue->getScope()->willReturn(null);
     $product->getValues()->willReturn([$skuValue]);
     // add 6 new values : 4 desc (locales x scopes) + 2 name (locales
     $product->addValue(Argument::any())->shouldBeCalledTimes(6);
     $this->addMissingProductValues($product);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:29,代码来源:ProductBuilderSpec.php

示例5: getRequiredAttributeCodes

 /**
  * Returns the required attribute codes for a product
  *
  * @param ProductInterface $product
  *
  * @return array
  */
 public function getRequiredAttributeCodes(ProductInterface $product)
 {
     $codes = [];
     if ($product->getFamily()) {
         $codes = $this->getFamilyAttributeCodes($product->getFamily());
     }
     foreach ($product->getGroups() as $group) {
         $codes = array_merge($codes, $this->getGroupAttributeCodes($group));
     }
     if ($product->getId()) {
         foreach ($product->getValues() as $value) {
             $codes[] = $value->getAttribute()->getCode();
         }
     }
     return array_unique($codes);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:AttributeCache.php

示例6: normalize

 /**
  * {@inheritdoc}
  *
  * @param ProductInterface $product
  */
 public function normalize($product, $format = null, array $context = [])
 {
     $defaultContext = ['filter_types' => ['pim.transform.product_value.structured']];
     $context = array_merge($defaultContext, $context);
     $context['entity'] = 'product';
     $data = [];
     if (isset($context['resource'])) {
         $data['resource'] = $context['resource'];
     }
     $data[self::FIELD_FAMILY] = null !== $product->getFamily() ? $product->getFamily()->getCode() : null;
     $data[self::FIELD_GROUPS] = $this->getGroups($product);
     $data[self::FIELD_VARIANT_GROUP] = null !== $product->getVariantGroup() ? $product->getVariantGroup()->getCode() : null;
     $data[self::FIELD_CATEGORY] = $product->getCategoryCodes();
     $data[self::FIELD_ENABLED] = $product->isEnabled();
     $data[self::FIELD_VALUES] = $this->normalizeValues($product->getValues(), $format, $context);
     return $data;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:ProductPropertiesNormalizer.php

示例7:

 function it_sets_attribute_when_new_value_is_different_from_product_value($builder, AttributeInterface $attribute, ProductInterface $product, FamilyInterface $family, ProductValue $productValue)
 {
     $family->getAttributeCodes()->willReturn(['sku', 'is_color']);
     $product->getFamily()->willReturn($family);
     $attribute->getCode()->willReturn('is_color');
     $product->getValue('is_color', null, null)->willReturn(null);
     $builder->addProductValue($product, $attribute, null, null)->willReturn($productValue);
     $this->setAttributeData($product, $attribute, true, ['locale' => null, 'scope' => null]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:9,代码来源:BooleanAttributeSetterSpec.php

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

示例9: array

 function it_normalizes_product(SerializerInterface $serializer, ProductInterface $product, FamilyInterface $family, Completeness $completeness)
 {
     $serializer->implement('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface');
     $this->setSerializer($serializer);
     $product->getFamily()->willReturn($family);
     $product->getGroups()->willReturn([]);
     $product->getValues()->willReturn([]);
     $product->getCompletenesses()->willReturn([$completeness]);
     $product->getCreated()->willReturn(null);
     $product->getUpdated()->willReturn(null);
     $product->isEnabled()->willReturn(true);
     $serializer->normalize($family, 'mongodb_json', [])->willReturn('family normalization');
     $serializer->normalize($completeness, 'mongodb_json', [])->willReturn(['completenessCode' => 'completeness normalization']);
     $this->normalize($product, 'mongodb_json', [])->shouldReturn([ProductNormalizer::FAMILY_FIELD => 'family normalization', ProductNormalizer::COMPLETENESSES_FIELD => array('completenessCode' => 'completeness normalization'), ProductNormalizer::ENABLED_FIELD => true]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:15,代码来源:ProductNormalizerSpec.php

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

示例11: getExpectedAttributes

 /**
  * Get expected attributes for the product
  *
  * @param ProductInterface $product
  *
  * @return AttributeInterface[]
  */
 protected function getExpectedAttributes(ProductInterface $product)
 {
     $attributes = [];
     $productAttributes = $product->getAttributes();
     foreach ($productAttributes as $attribute) {
         $attributes[$attribute->getCode()] = $attribute;
     }
     if ($family = $product->getFamily()) {
         foreach ($family->getAttributes() as $attribute) {
             $attributes[$attribute->getCode()] = $attribute;
         }
     }
     return $attributes;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:21,代码来源:ProductBuilder.php

示例12: updateProductValues

 /**
  * Sets the product values,
  *  - always set values related to family's attributes
  *  - sets optional values (not related to family's attributes) when a data is provided
  *  - sets optional values (not related to family's attributes) with empty data if value already exists
  *
  * @param ProductInterface $product
  * @param string           $attributeCode
  * @param array            $values
  */
 protected function updateProductValues(ProductInterface $product, $attributeCode, array $values)
 {
     $family = $product->getFamily();
     $authorizedCodes = null !== $family ? $family->getAttributeCodes() : [];
     $isFamilyAttribute = in_array($attributeCode, $authorizedCodes);
     foreach ($values as $value) {
         $hasValue = $product->getValue($attributeCode, $value['locale'], $value['scope']);
         $providedData = '' === $value['data'] || [] === $value['data'] || null === $value['data'] ? false : true;
         if ($isFamilyAttribute || $providedData || $hasValue) {
             $options = ['locale' => $value['locale'], 'scope' => $value['scope']];
             $this->propertySetter->setData($product, $attributeCode, $value['data'], $options);
         }
     }
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:24,代码来源:ProductUpdater.php

示例13:

 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

示例14: fillCompletenessesTemplate

 /**
  * Returns completenesses filled
  *
  * @param array            $completenesses
  * @param ProductInterface $product
  * @param array            $locales
  * @param string           $localeCode
  *
  * @return array
  */
 protected function fillCompletenessesTemplate(array $completenesses, ProductInterface $product, array $locales, $localeCode)
 {
     $allCompletenesses = $product->getCompletenesses();
     foreach ($allCompletenesses as $completeness) {
         $locale = $completeness->getLocale();
         $channel = $completeness->getChannel();
         $compLocaleCode = $locale->getCode();
         if (isset($completenesses[$compLocaleCode])) {
             $completenesses[$compLocaleCode]['channels'][$channel->getCode()]['completeness'] = $completeness;
             $completenesses[$compLocaleCode]['locale'] = $compLocaleCode;
             $completenesses[$compLocaleCode]['stats']['total']++;
             if (0 === $completeness->getMissingCount()) {
                 $completenesses[$compLocaleCode]['stats']['complete']++;
             }
         }
     }
     $requirements = $this->familyRepository->getFullRequirementsQB($product->getFamily(), $localeCode)->getQuery()->getResult();
     $productValues = $product->getValues();
     foreach ($requirements as $requirement) {
         if ($requirement->isRequired()) {
             $this->addRequirementToCompleteness($completenesses, $requirement, $productValues, $locales);
         }
     }
     return $completenesses;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:35,代码来源:CompletenessManager.php

示例15: getProductCompleteness

 /**
  * Returns an array containing all completeness info and missing attributes for a product
  *
  * @param ProductInterface                                    $product
  * @param \Pim\Bundle\CatalogBundle\Entity\ChannelInterface[] $channels
  * @param \Pim\Bundle\CatalogBundle\Entity\LocaleInterface[]  $locales
  * @param string                                              $localeCode
  *
  * @return array
  */
 public function getProductCompleteness(ProductInterface $product, array $channels, array $locales, $localeCode)
 {
     $family = $product->getFamily();
     $getCodes = function ($entities) {
         return array_map(function ($entity) {
             return $entity->getCode();
         }, $entities);
     };
     $channelCodes = $getCodes($channels);
     $localeCodes = $getCodes($locales);
     $channelTemplate = ['channels' => array_fill_keys($channelCodes, ['completeness' => null, 'missing' => []]), 'stats' => ['total' => 0, 'complete' => 0]];
     $completenesses = array_fill_keys($localeCodes, $channelTemplate);
     if (!$family) {
         return $completenesses;
     }
     $allCompletenesses = $product->getCompletenesses();
     foreach ($allCompletenesses as $completeness) {
         $locale = $completeness->getLocale();
         $channel = $completeness->getChannel();
         $compLocaleCode = $locale->getCode();
         if (isset($completenesses[$compLocaleCode])) {
             $completenesses[$compLocaleCode]['channels'][$channel->getCode()]['completeness'] = $completeness;
             $completenesses[$compLocaleCode]['stats']['total']++;
             if (0 === $completeness->getMissingCount()) {
                 $completenesses[$compLocaleCode]['stats']['complete']++;
             }
         }
     }
     $requirements = $this->familyRepository->getFullRequirementsQB($family, $localeCode)->getQuery()->getResult();
     $productValues = $product->getValues();
     foreach ($requirements as $requirement) {
         if ($requirement->isRequired()) {
             $this->addRequirementToCompleteness($completenesses, $requirement, $productValues, $locales);
         }
     }
     return $completenesses;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:47,代码来源:CompletenessManager.php


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