繁体   English   中英

如何在list.phtml中获得自定义的Magento属性?

[英]How can I get custom Magento attributes in list.phtml?

如何在Magento(版本1.4)产品类别列表(在list.phtml )中获得自定义属性?

我正在尝试通过添加来编辑catalog.xml

<action method="addAttribute"><code>format</code></action>

并在list.phtml

<?php echo $_product->getAttributeText('format'); ?>

要么

<?php echo $_product->getFormat(); ?>

但这是行不通的。 如何才能做到这一点?

它工作正常,只需将此代码放在list.phtml或view.phtml文件中所需的位置即可。

$attribute = $_product->getResource()->getAttribute('unit');
if ($attribute){
    echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM