Archive

Posts Tagged ‘custom attributes’

Magento Notes — How to reference custom product attributes

April 6th, 2009

One thing that I find very useful as I start to seriously customize the product details page for my B2B client is the ability to create custom attributes.  But it took me forever to figure out how to call them from the view.phtml which is the file you are most likely gonna be modifying as well as list.phtml, both located in: app\design\frontend\default\blue\template\catalog\product

If you have created a custom attribute of type dropdown list or other multi-select list, you will reference the attribute using:

<?php echo $_product->getAttributeText(’attribute_code‘) ?>

where the attribute_code is what you have setup in the admin interface when creating this custom attribute. For textboxes and text area data types, you will call these a little differently using:

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

where getAttributeName is a variable of “get” + “attribute_code” where if you have underscores (_) or dashes (-), they are removed, and each word’s first character is capitalized.  So for example, if you have an attribue code called: shirt_size, your call would be:

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

Note that it is case-sensitive.

The link here has additional information on this topic.

magento, technical notes ,