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:

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

Now after the function above I can start coding.


The function will only work for input text attributes.

It will looks like:

Where AttributeName will be your custom attribute:

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 Responses to “How to get Attributes Magento”

  1. Jeff June 8, 2010 at 11:44 pm #

    Im new to Magento and stumped by attributes, in particular showing them on the product page. Do you really need to add/modify code to show them ie its not just a case of enabling them in the front end from Admin?

    • quicoto June 9, 2010 at 8:19 am #

      Hey Jeff,

      When you go to the attribute edit page (backend) you have some options for showing it in the detail page.

      What I’m doing in this post is showing this attributes somewhere else (in the product list for example).

      Any questions you can post it here or in our Forums.


  2. Jeff August 3, 2010 at 11:07 pm #

    Hey this is a great post thank you so much! I’m working with Magento for the first time myself and this is invaluable information. Could you make a post about say creating a list of a custom attribute in the sidebar of your site? For instance l have a custom attribute “author_name”, say l wanted to output a list of all the different “author_name”s there are in the products table. That would be a huge help!

    • quicoto August 6, 2010 at 10:06 am #

      Hi Jeff,

      I just answered you by email.

      Thanks for commenting.


  3. David d'Edenzo November 20, 2012 at 12:40 pm #

    Thank you for this post !
    Magento is not simple….

    • Rick November 20, 2012 at 12:45 pm #

      You’re welcome 😉

  4. Kayla November 29, 2012 at 7:48 pm #

    Nice article!

    You mentioned:

    From car_color to getCarColor();

    I have an attribute with all caps attribute label, e.g. PRODUCT_COLOR

    How would you name that in the getAttributeName format? I have tried everything but nothing worked, it keeps showing up as undefined.

    For examples getProductColor(); getProductcolor(); etc. nothing worked 🙁

    Any help would be greatly appreciated!

    • Kayla November 29, 2012 at 7:49 pm #

      Sorry I meant PRODUCT_COLOR is the attribute code, not the label.

    • Rick November 29, 2012 at 9:30 pm #

      Now that’s interesting.

      Try the following:

      Let me know if this works.


    • Kayla December 10, 2012 at 11:49 pm #

      Hi Rick,

      Thank you for your reply. I have tried that before and it still would not work.

      I have been getting an error in my system.log file that said:

      “Recoverable Error: Object of class Mage_Catalog_Model_Resource_Eav_Attribute could not be converted to string”

      Not sure what to do…

  5. korm December 8, 2012 at 6:44 pm #

    hi, i try to do it in upsells.phtml but dont work, any idea? thanks a lot!

    • Rick December 8, 2012 at 8:26 pm #

      Have you tried the code in an other file? To make sure it’s not the code itself.


    • korm December 8, 2012 at 8:29 pm #

      yes in view and list.phtml

      thanks for reply!

    • Rick December 8, 2012 at 8:30 pm #

      You’re welcome !

    • korm December 8, 2012 at 8:31 pm #

      te puedo contestar en castellano? me gustaria poder hablar contigo si me mandas un email. muchas gracias

    • Rick December 8, 2012 at 8:34 pm #

      Claro. Puedes escribirme a:

      Saludos !

Leave a Reply

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