We recently upgraded one of our sites from Magento EE 22.214.171.124 to Magento EE 126.96.36.199. For the most part the upgrade was painless and much needed as it fixed several outstanding bugs. Any developer that has upgraded Magento knows that more often than not you can expect small issues either with the data or with the custom code running on the store.
In this particular case we started getting complaints from the catalog merchandising team about the speed on the backend, specifically the saving time once a product was created or updated. On average it was taking 2 to 3 min to save each product. We all know the backend of Magento can sometimes be a bit sluggish (lots of ways around this though), but 2-3 minutes is a little crazy to save a single product.
Our team decided to dig in and see if we could figure out why the Admin Product was saving extremely slow before escalating to Magento. Our first approach was to check the usual bottlenecks on a Magento site:
– Memory Usage
– Database bottlenecks
– Cpu usage
After a quick look at all of the usual suspects, everything looked normal. We suspected it was something non-server / configuration related since the site was actually performing very well in both frontend and backend with the exception of saving products.
One thing was called to our attention was the fact that the price indexes where running each time a product was saved; a quick test confirmed it and incredible enough each index refresh was taking between 2 and 3 minutes; so each time a product is saved, the price indexes for 10,000 products get refreshed. It’s also important to note that for performance reasons we only refresh the indexes on set intervals when the traffic is slow, so all indexes are set to manual update (no automated index refreshes here).
So our next step was to check if maybe one of the third party modules or our own extensions might be the cause of triggering the reindex event. A quick look at the code and configuration looking for observers attached to the product save event or maybe an override to a controller or a model returned nothing suspicious. Could this be a core Magento problem?
After poking around the core code I found a suspicious line of code inside the saveAction fucntion in the file:
app/code/core/Mage/Adminhtml/Catalog/ProductController.php around line 707:
And one google search later, my suspicions were confirmed. There are a couple of bug reports regarding this issue, notably http://www.magentocommerce.com/bug-tracking/issue/?issue=11036. Interestingly this bug appeared on Magento CE 188.8.131.52 and it’s still open; so I decided to try one of the suggest solutions and comment out this line of code. To properly to do it:
1) Copy the ProductController.php from app/code/core/Mage/Adminhtml/Catalog/ProductController.php to app/code/local/Mage/Adminhtml/Catalog/ProductController.php
2) Look for
and replace it with
That solved the issue and product updates went from taking 2-3 mins to only a few seconds. The only possible downside is that catalog rules are not being applied when the product save and full price reindex its still needed, in our case this works because we are already reindexing on a schedule and we don’t any reindexing to occur during the top traffic hours.