Jun 15, 2013
kalpesh

Magento get attribute label

To get attribute label for the product in Magento is not that straight-forward as we do for getting attribute value. You will need attribute code and product object to get the attribute label as shown below.

If you have the product object, you can use it to get the attribute’s label..

1
$label = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getLabel($product);

For the current/selected store view..

1
$label = $product->getResource()->getAttribute($attribute_code)->getStoreLabel();

This will output you the label of the attribute associated with the attribute code you passed for that product. E.g. Shirt Size, Color, etc..

To get select/dropdown attribute label by value OR to get select/dropdown attribute value by label, please check this post: http://ka.lpe.sh/2012/09/13/magento-get-product-attribute-select-option-idlabelvalue/

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications

Honor

Recognition

Magento top 50 contributors

Magento top 50 contributors

Contributions