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


PHP ProductInterface::getAttributes方法代码示例

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


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

示例1:

 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

示例2:

 function it_renders_a_product_with_an_image($templating, ProductInterface $blender, AttributeGroupInterface $media, AttributeInterface $mainImage, ProductValueInterface $productValue, FileInfoInterface $fileInfo, CacheManager $cacheManager)
 {
     $blender->getAttributes()->willReturn([$mainImage]);
     $blender->getValue("main_image", "en_US", "ecommerce")->willReturn($productValue);
     $productValue->getMedia()->willReturn($fileInfo);
     $fileInfo->getKey()->willReturn('fookey');
     $cacheManager->isStored('fookey', 'thumbnail')->willReturn(true);
     $mainImage->getGroup()->willReturn($media);
     $media->getLabel()->willReturn('Media');
     $mainImage->getCode()->willReturn('main_image');
     $mainImage->getAttributeType()->willReturn('pim_catalog_image');
     $templating->render(self::TEMPLATE_NAME, ['product' => $blender, 'locale' => 'en_US', 'scope' => 'ecommerce', 'groupedAttributes' => ['Media' => ['main_image' => $mainImage]], 'imageAttributes' => ['main_image' => $mainImage], 'uploadDir' => '/tmp/' . DIRECTORY_SEPARATOR, 'customFont' => null])->shouldBeCalled();
     $this->render($blender, 'pdf', ['locale' => 'en_US', 'scope' => 'ecommerce']);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:ProductPdfRendererSpec.php

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

示例4: getAttributes

 /**
  * Get attributes to display
  *
  * @param ProductInterface $product
  * @param string           $locale
  *
  * @return AttributeInterface[]
  */
 protected function getAttributes(ProductInterface $product, $locale)
 {
     return $product->getAttributes();
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:12,代码来源:ProductPdfRenderer.php


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