How to get Attributes Magento

Today I'm gona show you how to retrieve the product attributes in your Magento site.

First of all go to Catalog -> Attributes -> Manage Attributes

Edit your attribute. Set Used in product listing to yes.

In my case I want to add some of my own attributes to the product list.

Look for the product

Inside the file (it depens of where do you want to place the attributes) I look for:

$_product = $this->getProduct();

Just to be sure I have a variable wich contains the product.

Now after the function above I can start coding.

Examples

The function will only work for input text attributes.

It will looks like:

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

Where AttributeName will be your custom attribute:

<?php echo $_product->getMyShoes(); ?>
<?php echo $_product->getColor(); ?>

Function Format

You have to capitalize your attribute name from shoes to Shoes.

Please Notice

From car_color to getCarColor();

Drop down attributes

Check out How to get Dropdown Attributes Magento.

16 comments

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*