·

photo credit: triple-bacon-cheese.jpg via photopin (license)

How to solve the ever-growing core_url_rewrite table in Magento

Tags: , ,

Got an ever-growing core_url_rewrite  table in Magento? Don’t know what’s going on? I encountered this problem today: when I re-indexed my catalog URL’s, for some reason Magento added some extra rows. And it would keep on doing this each time I re-indexed it, when no product were even added, deleted or even modified. This was clearly a bug. But how to fix this?

The underlying cause

If you encounter this bug, chances are that you have one or more categories and/or products that share a similar product key. When this happens, Magentos’ indexer goes berserk and creates an ever-inflating table in your database, drastically decreasing performance on it’s way.

The fix

Lucky for you, you’re not the only one who encounters this strange behaviour. Also, a patch was released late 2013 that addresses this issue. If you don’t want to apply the patch and rather want to create your own module with a custom rewrite, simple rewrite the Mage_Catalog_Model_Url -model and rewrite the getUnusedPath() -method. After the following lines:

Add this:

And replace this:

With this:

 

Visitors give this article an average rating of 4.3 out of 5.

How would you rate this article?

3 thoughts on “How to solve the ever-growing core_url_rewrite table in Magento”

  1. Not Marco says:

    So looking forward to your next blog post!!

    1. Giel Berkers says:

      Thanks not buddy!

      1. cappie2000 says:

        Would you mind releasing this as a module?

Leave a Reply to cappie2000 Cancel reply