Display new product attribute on the category page

How to add attributes to product grid (list) in category? I believe that you have already created an attribute and now we have to display it.

  • Update layout xml (catalog.xml)
<layout>
<!--
Category default layout
-->
  <catalog_category_default translate="label">
<!-- ... -->
      <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<!-- ... -->
<!-- New Code -->
        <action method="addAttribute"><name>YourAttributeCode</name></action>
<!-- End New Code -->
      </block>
<!-- ... -->
  </catalog_category_default>
<!-- ... -->
<!--
Category layered navigation layout
-->
  <catalog_category_layered translate="label">
<!-- ... -->
      <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<!-- ... -->
<!-- New Code -->
        <action method="addAttribute"><name>YourAttributeCode</name></action>
<!-- End New Code -->
      </block>
<!-- ... -->
  </catalog_category_layered>
<!-- ... -->
</layout>



Also works

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

I use “ForCategoryDescription” attribute with code “for_category_description” for example.

  • Update layout xml (catalog/product/list.phtml)
 <?php echo $_helper->productAttribute($_product, $_product->getForCategoryDescription(), 'for_category_description'); ?> 

–°hecked for Magento version 1.4.2

Tags: , ,

Leave a Reply