Changing Category sort order takes a long time in Magento.

If you’re running a large Magento store, you may encounter an the dreaded “Please Wait” popup that hangs for a long period of time when attempting to move a category.

I looked into it, and discovered that Magneto was calling a reindexing process, which usually takes a bit of time to complete. You obviously don’t want to wait an eternity to move a single category, so you can simply do the following as a temporary way of disabling the reindexing when you move a category.

Disclaimer: This has been tested only on Magento 1.6.2

1. Open app/code/core/Mage/Catalog/Model/Category.php
2. Look for the following, around line 248:

Mage::getSingleton('index/indexer')->processEntityAction(
  $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
);
Mage::app()->cleanCache(array(self::CACHE_TAG));

3. Simply comment out this code like this:
/*Mage::getSingleton('index/indexer')->processEntityAction(
  $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
);
Mage::app()->cleanCache(array(self::CACHE_TAG));
*/

4. Save the file, and start moving your categories around instantly.

You can alternatively do this permanently by overriding the Category.php file by copying the file to app/code/local/Mage/Catalog/Model/Category.php and commenting out the code above.

Once you are done the sort order, you can apply the changes to the frontend by reindexing the catalog_flat_data Index, and clearing your Blocks HTML output caches.

Magento is a great platform, but sometimes I wonder why the developers make some of their decisions (like adding a resource intensive reindexing to a simple action like moving a category).

9 Comments

  1. safwan

    Its bad idea to change core files

    • Axel (Author)

      I agree with you. I mentioned this as a temporary fix (not intended to be a permanent fix). Alternatively I mentioned you can override the file permanently by moving it to the app/code/local/Mage/.... directory.

  2. fusion

    Thanks, this was a big help.
    Confirmed working in 1.8

  3. I agree it’s not good to change core code but I had a client’s site take minutes to move every single category and who has that kind of time.
    Could not see why it was doing it, so this bit of code (or editing of it) saved me hours, thanks.

  4. Daniel Hemmerich

    This was a big help, thanks a lot!

    If you can elaborate on how to take these steps, that would be very helpful:

    Once you are done the sort order, you can apply the changes to the frontend by reindexing the catalog_flat_data Index, and clearing your Blocks HTML output caches.

  5. You sir are awesome! This saved a butt ton of time managing our huge website.

    Confirmed working on 1.9

  6. Leland Smith

    Works for 1.9.1.0

    Thanks!

  7. Rukshan

    You can make the reindexing to “Manual update” form “Update on save”.
    Then save the categories and re-index manually afterwords. No need to do a code change.

  8. Confirm in magento 1.9.2.4

Leave a Reply to safwan