1. Home
  2. Prices
  3. Guided Tour
  4. New Shop
  5. Shop Review
  6. Ecommerce Marketing
  7. Ecommerce TV
  8. Magento Developers
  9. Portfolio
  10. Blog
  11. Contact
Home > Magento > Echo Product Attributes

Echo Product Attributes

Posted on: 5th Mar 2010 By: Adam Moss Leave a comment 1 Comment

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.

  • Twitter
  • AIM
  • WordPress
  • LinkedIn
  • Facebook
  • StumbleUpon
  • Technorati Favorites
  • Delicious
  • Ping
  • Digg
  • Bebo
  • Reddit
  • MySpace
  • NewsVine
  • Google Bookmarks
  • Sphinn
  • Propeller
Categories: Magento Tags:

One Response to “Echo Product Attributes”

  1. Display Custom Product Attributes in Magento, Magento Blog and E-Commerce

    [...] 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. [...]

Post A Comment