开发者

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

How can I get custom attributes in the Magento (version 1.4) category list of products (in list.phtml)?

I am trying to edit catalog.xml by adding

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

and开发者_Go百科 in list.phtml

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

or

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

But it doesn't work. How can this be done?


It works fine, just place this code to where you need in list.phtml or view.phtml file.

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


Load attributes via $_product->getAttributes()

http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Model_Product.html#getAttributes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜