I'm running into a problem in a Magento system where saving a large number of attributes either doesn't work at all, or only partially works. It appears to be a javascript related issue, and I was hoping someone on Stack Overflow had some "known science" for dealing with this situation, or could point me in the right direction.
The basic problem is, the Magento system in question has over 250 color attribute option labels. If an admin user attempts to manage these by doing the following
One of two things happens.
In Google Chrome on OS X, the button sticks in the "depressed" state, and after a period of time Google Chrome's "This page is not responsive" kill dialog comes up.
In a mozilla based browser on OS X, clicking the button makes the browser "think" for a bit, but it eventually submits the form. However, only a partial list of attribute labels is posted to the admin controller. This means the user can only edit the first 75 - 100 labels, since the other labels are never submitted.
I have reports from windows users describing the second behavior as well (browsers are non-specific)
The obvious answers are to either investigate the poorly performing javascript, or (Grouch Marx style) "don't do that". Before I spend the time profiling/excavating the javascript on that page, I was hoping there was some known fix for this, or specific knowledge as to what was causing the problem.
Magento CE 1.7.x, if it maters.
Update: The Javascript performance issues are a red herring. They're caused by the massive number of input fields being iterated through in
js/prototype/validation.js
Specifically in this try catch block
try {
if(this.options.stopOnFirst) {
result = Form.getElements(this.form).all(function(elm) {
if (elm.hasClassName('local-validation') && !this.isElementInForm(elm, this.form)) {
return true;
}
return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback});
}, this);
} else {
result = Form.getElements(this.form).collect(function(elm) {
if (elm.hasClassName('local-validation') && !this.isElementInForm(elm, this.form)) {
return true;
}
return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback});
}, this).all();
}
} catch (e) {
}
However, even if I short circuit this and have the function return true, the behavior of not saving all the labels persists.
You can try the variable max_input_vars (introduced in PHP 5.3.9), by default it's 1000 so that should be enough, but maybe your configuration uses a lower amount. But I imagine the form just doesn't get through due to the major performance issues you're experiencing.
About the option labels: do they by any change have an uploader for an attribute-image? We had the exact same problem when we installed the GoMage Advanced Navigation extension on a shop with over 300 manufacturer options (the extension uses Magento's built-in Flash-uploader).
We didn't have the extension for that feature so I disabled the uploader, but the extreme performance decrease was definitely in the 300 Flash-movies being loaded. Maybe you can try lazyloading the uploader on a per-option basis by inserting a button or link instead of the movie.
Hope this points you in the right (or exact) direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With