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


PHP ProductInterface::getName方法代码示例

本文整理汇总了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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:33,代码来源:ProductVariationsBuilder.php

示例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()];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Grouped.php

示例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;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:10,代码来源:Item.php

示例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);
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:10,代码来源:RedirectIfOneResult.php


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