rss
twitter
    Find out what I'm doing, Follow Me :)

Monday, December 7, 2009

Pin It

Widgets

Magento: Displaying Custom Attributes on Product View

Adding custom attributes to your product view is very easy. Adding them to the product listing (category pages) is much more difficult. You’ll need to create a custom module for that. In this post though, I’ll only be showing you how to add attributes to the product view page.

If it is a text field (textbox or textarea), this is all you have to do:

<?php echo $_product->getAttributeName() ?>

There is one thing different here though. If your Attribute Code is “shirt_size”, then you would use getShirtSize(). Remove the underscores and capitalize the first letter of each word. It is picky that way. if you use getshirtsize(), it won’t work.

If you are using a dropdown or a multiple select, you have to call it a little differently:

<?php echo $_product->getAttributeText('shirt_size') ?>

This method requires the actual Attribute Code. If you are displaying the value from a dropdown, you’ll get exactly what you need with this call. If you are wanting to display the values from a multiple select, it will return an array.



Source : http://devzone.pratthost.com/

No comments:

Post a Comment