Timeout saving attribute options (for types “multiple select” and “dropdown”)

During my daily work, I have noticed that the admins of some Magento stores are experiencing problems when they have to work with attributes of type “Multiple Select” and “Dropdown”, which have many options (for example more than one thousand options). When they pressed the save button in the admin area, after they edited an attribute, their browser crashed.

Some people wrote about the problem here:

The source of the problem was in the Javascript used for input-validation. While this script iterates over all form elements it creates serious performance issues and the bowser freezes or crashes.

Solution

I created an extension you can install and try in your Magento stores. The extension works well if you have added new options to an attribute which already has many saved options. If you are just creating new attribute and you added thousands of options, then you will experience the problem, but for example if you save the attribute options on small chunks, e.g. 500 options at a time, then everything should be fine.

You can download the extension from here: https://github.com/Jarlssen/Jarlssen_FasterAttributeOptionEdit

More details (for developers):

All the logic for the fix is placed in a template file: jarlssen/faster_attribute_option_edit/options-fix.phtml
I had to rewrite Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options to replace the original options template file with mine.

Instead of creating input fields for all existing options I used placeholders faking the inputs. When we click on any of the placeholders the placeholder is replaced with real option inputs (using DOM manipulations).

Placeholder markup:

Real option:

There are some styles in the bottom of jarlssen/faster_attribute_option_edit/options-fix.phtml, because I didn’t want to add more external files. Also I had to fake the checkboxes and radio buttons – I created an element using base64 encoded images of checkboxes and radio buttons as a background-image.

Because I use placeholders I display the information about the options, but I skip the Javascript validation, because the information is not kept in form inputs. Also in the post data I sent only the newly added options and the edited options.

Hope this helps!

Proof reading by Oliver Baumann.
Thanks!

  • Potenc

    Hi

    I am having the exact option discribed. Which file do i exactly install?

    Thank you

    • Tsvetan Stoychev

      Hello you can download the module from here: github.com/Jarlssen/Jarlssen_FasterAttributeOptionEdit/archive/master.zip

      When you download it you can extract the module inside your Magento directory and after that you have to clear the cache.

      • Marco

        Hello, i have downloaded the module and uploaded in the root of my Magento directory, cleared the cache, but i still takes alot of time when i choose to save the attributes, and it doesn’t save them. Any ideas? I am using Magento 1.7.

        • Tsvetan Stoychev

          Hi @disqus_UtgZEV6u5a:disqus ,

          The problem can be caused, because of collision with another extension or some JS error. Can you check for any JS errors and you server logs for any error or warning messages?

  • Nelson Suniaga

    Tested on Magento 1.9.1.0…works perfect! thank you so much!

  • Aad Mathijssen

    This is awesome. Thanks for this plugin!