Magento 2专家, 你可以帮我,在magento 2产品详情页面中隐藏空/ NA属性吗?
非常感谢
答案 0 :(得分:1)
嗯,这是magento核心问题:https://github.com/magento/magento2/issues/9961,但您现在可以使用以下解决方案。
从以下网址获取attributes.phtml文件:/vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtml
复制此文件并粘贴到您的主题:/ app / design / frontend / [您的包裹] / [您的主题] /template/catalog/product/view/attributes.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中完美运行