blog

Getting Custom Attributes in Magento

published in

Magento

comments

2

One of the flexible features of Magento is the ability to create custom attributes for products. This allows you to display and use any type of information for your products. It also allows you to specify options and choices when the user purchases the product. Often these custom attributes need to be displayed on the product detail pages. Let’s assume you are familiar with making custom attributes – so here are a few quick snippets to access Magento’s custom attributes:

Text Attributes

// Display the value of a text attribute
// Where getAttributeCode is the value you entered for the attribute code
<?php echo $_product->getAttributeCode; ?>

Textarea Attributes

// Display the value of a text area custom attribute
// Where attributeCode is the value you entered for the attribute code
<?php echo $_product->attributeCode; ?>

Drop Down Attributes

// Display the value of a drop down custom attribute
// Where attribute_code is the value you entered for the attribute code
<?php echo $_product->getAttributeText('attribute_code'); ?>

Check back for more snippets on each attribute type – as I come across the need for them I will add to this article.

This entry was posted in Magento and tagged , , , , . Bookmark the permalink.

2 Responses to Getting Custom Attributes in Magento

  1. Ian Walker says:

    Looked all over for this – worked great.

    Cheers,
    Ian

  2. Pingback: Magento Custom Attributes in Product List | Bret Glassett – Denver web developer || Magento development, Wordpress development, Drupal development. ExpressionEngine development

Leave a Reply

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

*

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>