本文整理汇总了PHP中Magento\Catalog\Api\Data\ProductInterface::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::getName方法的具体用法?PHP ProductInterface::getName怎么用?PHP ProductInterface::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Api\Data\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Populate product with variation of attributes
*
* @param \Magento\Catalog\Api\Data\ProductInterface $product
* @param array $attributes
* @return \Magento\Catalog\Api\Data\ProductInterface[]
*/
public function create(\Magento\Catalog\Api\Data\ProductInterface $product, $attributes)
{
$variations = $this->variationMatrix->getVariations($attributes);
$products = [];
foreach ($variations as $variation) {
$price = $product->getPrice();
/** @var \Magento\Catalog\Model\Product $item */
$item = $this->productFactory->create();
$item->setData($product->getData());
$suffix = '';
foreach ($variation as $attributeId => $valueInfo) {
$suffix .= '-' . $valueInfo['value'];
$customAttribute = $this->customAttributeFactory->create()->setAttributeCode($attributes[$attributeId]['attribute_code'])->setValue($valueInfo['value']);
$customAttributes = array_merge($item->getCustomAttributes(), [$attributes[$attributeId]['attribute_code'] => $customAttribute]);
$item->setData('custom_attributes', $customAttributes);
$priceInfo = $valueInfo['price'];
$price += (!empty($priceInfo['is_percent']) ? $product->getPrice() / 100.0 : 1.0) * $priceInfo['pricing_value'];
}
$item->setPrice($price);
$item->setName($product->getName() . $suffix);
$item->setSku($product->getSku() . $suffix);
$item->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE);
$products[] = $item;
}
return $products;
}
示例2: fillData
/**
* Fill data column
*
* @param ProductInterface $linkedProduct
* @param ProductLinkInterface $linkItem
* @return array
*/
protected function fillData(ProductInterface $linkedProduct, ProductLinkInterface $linkItem)
{
/** @var \Magento\Framework\Currency $currency */
$currency = $this->localeCurrency->getCurrency($this->locator->getBaseCurrencyCode());
return ['id' => $linkedProduct->getId(), 'name' => $linkedProduct->getName(), 'sku' => $linkItem->getLinkedProductSku(), 'price' => $currency->toCurrency(sprintf("%f", $linkedProduct->getPrice())), 'qty' => $linkItem->getExtensionAttributes()->getQty(), 'position' => $linkItem->getPosition(), 'thumbnail' => $this->imageHelper->init($linkedProduct, 'product_listing_thumbnail')->getUrl(), 'type_id' => $linkedProduct->getTypeId(), 'status' => $this->status->getOptionText($linkedProduct->getStatus()), 'attribute_set' => $this->attributeSetRepository->get($linkedProduct->getAttributeSetId())->getAttributeSetName()];
}
示例3: getData
/**
* Item data.
*
* @return array
*/
public function getData()
{
$productItemData = ['id' => $this->product->getId(), 'name' => $this->product->getName(), 'price' => $this->getProductPrice(), 'image' => $this->productHelper->getSmallImageUrl($this->product), 'score' => $this->product->getDocumentScore(), 'is_in_stock' => $this->isInStockProduct()];
return $productItemData;
}
示例4: addRedirectMessage
/**
* Append message to the customer session to inform he has been redirected
*
* @param \Magento\Catalog\Api\Data\ProductInterface $product The product being redirected to.
*/
private function addRedirectMessage(ProductInterface $product)
{
$message = __("%1 is the only product matching your '%2' research.", $product->getName(), $this->helper->getEscapedQueryText());
$this->messageManager->addSuccessMessage($message);
}