本文整理汇总了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);
}
示例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']);
}
示例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;
}
示例4: getAttributes
/**
* Get attributes to display
*
* @param ProductInterface $product
* @param string $locale
*
* @return AttributeInterface[]
*/
protected function getAttributes(ProductInterface $product, $locale)
{
return $product->getAttributes();
}