Get Multiple Select Product Attribute’s Option Labels Instead of Option IDs in Magento

attributesproduct-attribute

I have a product attribute, Available Sizes in Magento. The input type is Multiple Select.

The options for the attribute are Small, Medium and Large.

enter image description here

Normally when I call a product attribute on the frontend, I use echo $_product->getAttributeCode();

With this attribute, when I use echo $product->getAvailableSizes(); it is giving me the values for the product like 13 or 14,13 – I assume these are the IDs of the options, rather than the labels.

I want to print out the options as text rather than IDs.

What I want is something like Small or Small,Medium. Can I get the attribute in this format without having to resort to if statements like if value is 13, echo "Small" etc. I want to do something more dynamic than that if possible!

For reference I am working on the catalog/product/view.phtml and catalog/product/list.phtml views.

Many thanks. I'm working with EE 1.14.0.1.

Best Answer

Try this:

$product->getAttributeText('available_sizes');
Related Topic