Magento Slow

Hello.

After an intense debug into Magento, we (Filipe Ibaldo and me) have found two problems in Magento code, related to slow Place Order with many products in cart (not many qty of a product).

One of the problems is the order item save, which is executed precisely in app/code/core/Mage/Sales/Model/Entity/Order/Attribute/Backend/Parent.php, on afterSave method, who spent many time on my machine (Core 2 Duo 2.26/4GB RAM), about 0.3 second for each product.

Considering the number of items average of customer’s cart is about 50 distinct products, this time, adding to another code executions and a high server load, is easily more than one minute, and this is unacceptable.

The found workaround is disable some observers from Mage_Downloadable and Mage_Rss, who execute in afterSave of each item in order.

In app/code/core/Mage/Downloadable/etc/config.xml, remove/comment the following lines:

            <sales_order_item_save_after>
                <observers>
                    <downloadable_observer>
                        <class>downloadable/observer</class>
                        <method>saveDownloadableOrderItem</method>
                    </downloadable_observer>
                </observers>
            </sales_order_item_save_after>

The code above appears twice.

In app/code/core/Mage/Rss/etc/config.xml, remove/comment the following lines:

            <sales_order_item_save_after>
                <observers>
                    <notifystock>
                        <class>rss/observer</class>
                        <method>salesOrderItemSaveAfterNotifyStock</method>
                    </notifystock>
                </observers>
            </sales_order_item_save_after>
            <sales_order_item_save_after>
                <observers>
                    <ordernew>
                        <class>rss/observer</class>
                        <method>salesOrderItemSaveAfterOrderNew</method>
                    </ordernew>
                </observers>
            </sales_order_item_save_after>

With this workaround, the save time of each product went from 0.3 second to 0.001 second, an incredible speed improvement.

However, if you are using downloadable products or Magento Inventory Management, this modifications can broke related features, so, be careful.

Another problem found is related with module disable feature into System > Configuration > Advanced > Advanced > Disable Module Output. If you disable some module, their observers did not disabled, and you need to remove their configuration or delete module folder.

Bye.

  1. Thank you soooooo much for this article! I was searching for this solution everywhere!

    • Sean
    • March 8th, 2011

    If you truly are not using the Downloadable Products module, the best bet probably would be to not just disable the observers, but save the overhead and disable the module completely.

    In 1.4.1.1, in app/etc/modules, you will find Mage_Downloadable.xml

    Find the <active> tag and change the contents from true to false to disable the module. If you need it in future, the configs and files will remain intact.

    • Sean
    • March 8th, 2011

    To disable the RSS module, find Mage_Rss in /app/etc/modules/Mage_All.xml and put false between the active tags. Again this is in 1.4.1.1

  2. Hi,

    Thanks for this. To disable these two modules (Mage_Downloadable and Mage_Rss) in the code (and not the Magento backend) while NOT removing their files: You can also modify their XML-definition in the folder “app/etc/modules”. The file Mage_Downloadable.xml is easy to find, while Mage_Rss is located in the Mage_All.xml file. Set the active-flag from true to false. This allows you to easily re-enable the module if you need to.

    Jisse

    • ahamed sha
    • July 2nd, 2012

    thank you for the fix. it really improved the submitting order information part by 60sec ++ to just 2 secs. i added 50 items to test and applied the fix.

  3. Excellent fix. 30sec+ to ~5secs

  1. No trackbacks yet.