Echo Product Attributes
A short and simple post from me today, but something that beginner Magento developers might want to know – how to echo individual product attributes on the product view.phtml page. It’s one of those things that you’ll probably want to do at some point, but you don’t know quite where to look.
First create an attribute, which you’d name accordingly. In this example, a pen has attribute ‘pen_colour’.
On app/design/frontend/base/yourtheme/catalog/product/view.phtml add the following code somewhere within the main conditional statement:
<?php echo $_product->getAttributeText('pen_colour') ?>
If you want to echo the same thing on the product listing page, simply add this similar code to the following file: On app/design/frontend/base/yourtheme/catalog/product/list.phtml within each conditional statement:
<?php echo $_product->getResource()->getAttribute('pen_colour')->getFrontend()->getValue($_product) ?>
You also need to ensure that in the attribute settings:
Visible on Product View Page on Front-end is set to ‘Yes’
Used in product listing is set to ‘Yes’
Now you should be able to see attributes echoed onto that pages, separate from the ‘Additional Information’ tab where they normally reside.

July 7th, 2010
[...] Relatively easy on the surface, and, granted, applicationĀ this is a question that comes up fairly often – so I thought I’d answer it. This is a topic we’ve covered before with a slightly different method on our Magento Blog at Ecommerce web design, and you can read Adam’s earlier post here. [...]