24

Oct

Showing product attributes on category and product pages in Magento

If you’re looking for a way to show product attributes on your category and product pages in Magento, it’s actually quite simple.

I’ve seen quite a few blog posts and Magento forum topics well and truly over complicating this.

There are two steps involved:

Enabling the attribute for front end display

If you don’t do this, you won’t see your attribute on the category or product page and you’ll be scratching your head trying to work out why your get attribute function is shooting blanks.  Do the following:

  1. In admin, go to Catalog > Attributes > Manage Attributes
  2. Select the attribute you want to edit
  3. Scroll down to Frontend Properties and select Yes for Used in product listing

Adding some code to your template files to return the attribute

This couldn’t be easier.  There is a function in the Mage_Catalog_Model_Product class called getAttributeText that takes one argument, the attribute code.

Add the following code to your catalog/product/view.phtml or catalog/product/list.html template files:

echo $_product->getAttributeText('your_attribute_code');

Just change out ‘your_attribute_code’ with your attribute code and you’re done.  That’s it.  Simple hey?

Share |

Leave a Reply

Your email address will not be published. Required fields are marked *

*


8 + = twelve

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>