dongshun5963 2018-09-26 00:47
浏览 29
已采纳

Magento 2 - 产品中默认没有制造商或品牌属性

I need to use for my extension either a brand attribute or a manufacturer attribute in the products. Nevertheless, I cannot find any attribute that corresponds to that case.

For example, doing something like these returns nothing:

$this->_logger->debug(' Manufacturer ' . $product->getAttributeText('manufacturer'));

And something like these:

$this->_logger->debug('Manufacturer ' .$product->getManufacturer());

raises an exception.

Am I missing something or it doesn't exist by default?

  • 写回答

1条回答 默认 最新

  • dongpin2969 2018-09-26 06:56
    关注
    • Make sure that you have assigned "manufacture" or "brand" attribute
      to appropriate product Attribute Set.
    • Make sure you have enter values manufacture or brand for the product as well.

    You can get attribute text by using below code.

    echo $_product->getAttributeText('manufacturer');
    
    echo $_product->getAttributeText('brand');
    

    if $_product doesn't work for you then try below code to get product data.

    $_product = $this->getProduct();
    

    OR

    $_product = $block->getProduct();
    

    Accept if this answer is helpful to you.

    Source link answered here as well

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决