magento 2空的属性隐藏在产品详细信息页面

magento 2空的属性隐藏在产品详细信息页面

问题描述:

Magento 2专家, 你能帮我,隐藏magento 2产品详细信息页面中的空/ NA属性吗?magento 2空的属性隐藏在产品详细信息页面

非常感谢

+0

同样的问题,可以正常使用:https://开头计算器。 COM /问题/ 44665119 /如何去除的空的属性-NA-在-Magento的-2 – Alex

嗯,这是Magento的核心问题是:https://github.com/magento/magento2/issues/9961,但是你可以用下面的,现在的解决方案。

获得从attributes.phtml文件:/vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtml

复制这个文件,并在你的主题贴:/应用/设计/前端/ [你的包装]/[你的主题] /模板/目录/产品/视图/属性.phtml。

搜索下面的代码:

<tr> 
     <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th> 
     <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td> 
    </tr> 

通过下面的代码替换上面代码:

<?php 
     $_attribute = $_product->getResource()->getAttribute($_data['code']); 

     if (!$_attribute->getFrontend()->getValue($_product)) { 
      continue; 
     } 
    ?> 

    <tr> 
     <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th> 
     <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td> 
    </tr> 

以上解决方案在Magento 2.2