I have a dropdown attribute with many options.

In cart.phtml I already get the attribute value for each item


In addition to that I want to get the option position.

How can I do that without loading all Attribute options.

  • So, you start a bounty, people waste their time to help, and then you don't even validate the answers... Not fair, man – Raul Sanchez Mar 16 '16 at 7:53
  • Sorry, I'll do it now :) – Bizboss Mar 16 '16 at 10:32
  • Nice ;) Regards, man – Raul Sanchez Mar 16 '16 at 10:34

Assuming you have $optionId ( that's the value you get when calling $product->getData('your_attribute') ), you can get the position (sort_order) this way

$options = Mage::getResourceModel('eav/entity_attribute_option_collection')

This will return a simple object, something like...

    [option_id] => 624
    [attribute_id] => 298
    [sort_order] => 0

Check Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection for more details

| improve this answer | |
  • sorry I have tried it and it don't work ! :( – Bizboss Mar 31 '16 at 10:22

Raul was almost correct, but his answer returns a collection, not a simple object. For a specific attribute option it would be:

$option = Mage::getResourceModel('eav/entity_attribute_option_collection')

Or to get the sort order (position) of the option directly:

$position = Mage::getResourceModel('eav/entity_attribute_option_collection')
| improve this answer | |
  • Thumbs up for you ;) – Raul Sanchez Apr 23 '18 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.