<reference name="content"> <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml"> <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"> <!-- edit oliver attribute on list --> <action method="addAttribute"><code>my_weight</code></action> <!-- edit oliver attribute on list --> </block> </block> </reference>
<reference name="content"> <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml"> <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"> <!-- edit oliver attribute on list --> <action method="addAttribute"><code>my_weight</code></action> <!-- edit oliver attribute on list --> </block> </block> </reference>
Ignore my previous post, it was just a shot in the dark plus I’m a newbie, so forgive me. Back to the issue at hand, is there a function called addAttribute in the file called List.php in the core?
A possible solution is to add your attribute to layer model file ( app/code/core/Mage/Catalog/Model/Layer.php )
to the function prepareProductColletion($collection) at line 56
->addAttributeToSelect('my_attribute')
Only after that, you can do
$_product->getData('my_attribute')
in the template.
Note: This is not elegant. Elegant would have been to be able to do
The code “author” was used as an example above.
You will have to insert the desired attribute code (found under ‘Manage Attributes’ in Magento Admin).
Please pay attention to capitalization.
Only the attribute value is pulled with this function and not the label of the attribute (in this case “Author"), as opposed to the product pages which list both. So in the case of the example above, you would want to ad “Author:” or the like, in front of it, if desired, for example like this: