0

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 in list.phtml

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

or

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

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

sth
  • 222,467
  • 53
  • 283
  • 367
Adomas
  • 21
  • 2
  • 3
  • possible duplicate of [how to display product detail description on product listing page?](http://stackoverflow.com/questions/6027532/how-to-display-product-detail-description-on-product-listing-page) – clockworkgeek Aug 01 '11 at 13:36

2 Answers2

1

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);
}
Y.Puzyrenko
  • 2,166
  • 1
  • 15
  • 23
Ramesh
  • 192
  • 1
0

Load attributes via $_product->getAttributes()

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

usoban
  • 5,428
  • 28
  • 42