将自定义属性添加到产品列表中
-
16-10-2019 - |
题
我对目录/product/list.phtml文件中的一个小问题感到非常困惑。
我正在尝试将Magento随附的制造商属性添加到我的网格列表中,并添加了以下代码。
<?php echo $_product->getAttributeText('manufacturer') ?>
<?php if( $_product->getAttributeText('manufacturer') ): ?>
<p class="manufacturer">Manufactured by:<br/><?php echo $_product->getAttributeText('manufacturer')?></p>
<?php endif; ?>
现在,这是我在产品/view.phtml页面上使用的代码,并且可以在此处使用。但这根本不起作用,即自我回声或在if语句中使用它。两者都没有返回。
因此,我必须做一些特别的事情才能在list.phtml文件上获取这些属性?
解决方案
确保属性 manufacturer
(以及您要列出的其他)有标志 Use in product listing
调成 Yes
. 。设置标志后,您应该重建产品平面索引 Flat catalog
已启用。