[Solved] Sort Configurable Product Attribute Options and Dropdowns

So there’s this new problem that has crept into Magento 1.9.1. When you create a configurable product the attribute options resort themselves by the Simple product IDs instead of your stated sort order. To fix this problem you will need to apply the patch file that I’ve created below.

Step 1 : Creating the overriding file structure

You will need to create the following folder structure, because most likely it does not exist. This file structure will override the original file and allow you to maintain an upgrade safe patch to your Magento installation. I’ve bolded the local folder in this breadcrumb because it’s where you will need to start creating folders.


Step 2 : Creating the patched file

Inside of the last folder that you created, Attribute, you will need to create a new file called Collection.php and paste into the contents of my patch below.

Keep Reading

catalog product1configurable options1Magento28


    April 29, 2015 - 4:23 pm

    Thanks so much! Worked perfectly. Can’t believe what a big bug this is. Thanks for your help!



      May 2, 2015 - 7:00 pm

      No Problem Kristen! I try to post as much as I can, unfortunately I have a huge backlog of fixes and optimizations that I haven’t been able to post yet.


    Shaun O’Hagan

    May 8, 2015 - 9:41 pm

    Thanks for this fix. A very annoying bug. The new site we are building has loads of configurable products with things kike weights 1.1, 1.2, 1.3 … 1.10, 1.11 which of course meant our pull downs were 1.1, 1.10, 1.11, 1.2

    Saved me a load of pain.


    lan nguyen

    June 4, 2015 - 7:43 am

    It’s bad if your site have more than 1000 childs product. After this fix, my site performance become slower than 10 seconds. From 2.5s become to 11.2s. I’m not recommend this method if your site have alot of attribute to load.
    This one is causing my site slower than it should be.
    TTT4:Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection::_afterLoad 8.8884 1 7,338,240 9,437,184


    lan nguyen

    June 4, 2015 - 8:07 am


    Finally, I found out why. Let’s me explain
    I go to core and copy exactly this file.
    and paste to local

    After that, i get your fixed code from line 299 to 319 and put it to Collection.php on local. My site is working fine now. I can’t compare your what is different your above and core code. But it’s fixed

    Thank you so much, Jonathon
    You saved my live.
    This is really annoying bug, I can’t image it exist on the lastest magento updated
    I hope this can help another people.

    Thank again!


      JJ NINI

      January 30, 2016 - 8:30 pm

      I’ve tried your method but copying lines 299 to 319 of a collection.php from Magento 1.9.2 it give error
      Do you test it in this version?
      Can you send me the modified file (in case I do it wrongly)


      Yaeger Design

      May 27, 2016 - 5:03 pm

      Perfect, thanks!


    JJ Shaw

    June 5, 2015 - 3:50 pm

    Thanks a lot for this – it helped me – I really appreciate you spending the time to post.



    July 21, 2015 - 8:12 am

    Goodmorning Jonathon,

    Thanks for the fix, it worked like a charm and solved a big problem for us!

    Kind regards and keep up te good work,




    July 23, 2015 - 10:50 am

    Works Well done !


    santhosh kumar

    August 4, 2015 - 11:15 am

    It can be done in the first loop only. No need to re-looping the whole items once more. Added “#changed code”, on the code changes.

    $optionsByValue = array();
    $sortOrders = array(); #changed code
    $sortOrder = 1; #changed code
    foreach ($options as $option) {
    $optionsByValue[$option[‘value’]] = $option[‘label’];
    $sortOrders[$option[‘value’]] = $sortOrder++; #changed code

    foreach ($this->getProduct()->getTypeInstance(true)
    ->getUsedProducts(array($productAttribute->getAttributeCode()), $this->getProduct())
    as $associatedProduct) {

    $optionValue = $associatedProduct->getData($productAttribute->getAttributeCode());

    if (array_key_exists($optionValue, $optionsByValue)) {
    // If option available in associated product
    if (!isset($values[$item->getId() . ‘:’ . $optionValue])) {
    // If option not added, we will add it.
    $values[$item->getId() . ‘:’ . $optionValue] = array(
    ‘product_super_attribute_id’ => $item->getId(),
    ‘value_index’ => $optionValue,
    ‘label’ => $optionsByValue[$optionValue],
    ‘default_label’ => $optionsByValue[$optionValue],
    ‘store_label’ => $optionsByValue[$optionValue],
    ‘is_percent’ => 0,
    ‘pricing_value’ => null,
    ‘use_default_value’ => true,
    ‘sort_order’ => $sortOrders[$optionValue] #changed code
    # changed code
    usort($values, function($a, $b) {
    return $a[‘sort_order’] > $b[‘sort_order’];



      February 25, 2016 - 4:39 am

      Working like a charm, thank you!


      Yaeger Design

      May 27, 2016 - 4:40 pm

      This gave a 500 error for me.


    Noah Wilcox

    August 21, 2015 - 7:16 pm

    This is a great fix. I was having difficulties puting in Lbs. such as 2 Lbs., 5 Lbs. and 10Lbs. 10 Lbs. kept showing up before 2 and 5 Lbs.

    This code did the trick! I appreciate it.

    I am curious though about what lan nguyen commented about. How much of an effect will this have on site speed if any at all? We have a large number of attributes on one of our sites. I have done multiple hard refreshes and have not noticed a site speed effect, however I would rather not check all attribute sets that we have to find out for each product and set.


    Jeff Grech

    September 3, 2015 - 7:13 pm

    I do not see the patch code. Was it deleted?? I am having the same problem!



      September 6, 2015 - 3:20 am

      Make sure to clear your cache and reset the compilation if you have it turned on.


    Buster Buttons

    September 9, 2015 - 8:34 pm

    Unacceptable that this is not being fixed NOW. Magento/ebay snap out of your trance and justify your outrageous salaries!



    September 11, 2015 - 3:47 pm

    Thank you so much, works like a charm!



    December 3, 2015 - 4:09 am

    Thanks! Work Perfectly



    December 29, 2015 - 6:47 am

    Thank you!! This was really helpful. Works perfectly.


    Gadget Man Jay

    January 29, 2016 - 6:48 am

    Hi, I applied this patch which seems to work for configurable products, but I seem to have a bigger problem. ALL my dropdowns for attributes iNCLUDING the attribute sets themselves when creating a new product from scratch don’t order alphabetically!

    Please help as this is driving me insane!



    January 30, 2016 - 8:22 pm

    Thanks for this, I succeed in adding this in our 1.9.2 Magento store but we still have an issue.
    We use it in configurable products and for size
    The fix correct the sort in product page only for size in numbers (34, 36..) but not the XS, S, M, L XL… for the letter is still not sorted
    And in product list the numbers are not sort and the letters yes !!!

    Any idea?


      Richard Creek

      April 7, 2016 - 9:34 am

      I was having the same problem with 1.9.2 and I found there’s another file that needs modifying.

      Copy: Mage/Catalog/Block/Product/View/Type/Configurable.php to local
      Edit the method: getJsonConfig()

      From line 197, change to this:

      $info[‘options’][] = array(
      ‘id’ => $value[‘value_index’],
      ‘label’ => $value[‘label’],
      ‘price’ => $configurablePrice,
      ‘oldPrice’ => $this->_prepareOldPrice($value[‘pricing_value’], $value[‘is_percent’]),
      ‘products’ => $productsIndex,
      ‘sort_order’ => $value[‘sort_order’] //new code
      $optionPrices[] = $configurablePrice;

      // new code
      usort($info[‘options’], function ($a, $b) {
      return $a[‘sort_order’] > $b[‘sort_order’];

      * Prepare formated values for options choose


        Yaeger Design

        May 27, 2016 - 5:02 pm

        I modified the code to match the original post and it works perfect, thanks!!!



        July 1, 2016 - 5:25 am

        I copie the Configurable.php to /app/code/local/Mage/Catalog/Block/Product/View/Type and made the changes. After that, the Dropdown is empty



          July 1, 2016 - 5:40 am

          Sorry – forgot one subdirectory



    April 8, 2016 - 6:28 am

    Is there a solution for Magento I can’t find anything on the Internet. It’s so embarassing.



      May 10, 2016 - 8:03 pm

      Worked for me – I have as of 5/8/16.



    May 10, 2016 - 8:01 pm

    Uh… like… AWESOME!!!!!


    Yaeger Design

    May 27, 2016 - 5:04 pm

    A combination all these comments is working perfectly in!



    August 3, 2016 - 3:55 am

    Worked absolutely perfectly for me! It’s very rare I see such an out of the box bug fix for Magento ( is my version).

    I’m also using Simple Configurable Products so naturally I was a bit concerned. But no, worked great!


Your email address will not be published. Required fields are marked *