Tag Archives: Indexes

Fixing Magento URL Rewrite Indexing Error

Recently, I was trying to rebuild Magento indexes when I was presented with this extremely informative error message:


An error occurred while saving the URL rewrite

…Seriously?

Magento’s error reporting can be very good, or very bad. Unfortunately in this case it’s bad.
No amount of index rebuilding would make this go away, and the red “Rebuild Required” flag next to the URL Rewrites index was doing nothing but filling my heart and body with an insurmountable rage.
A Google search for a fix produced some results that included 777ing the media folder, and other such “solutions”, but nothing of value. There seemed to be a lot of people left in the lurch, unable to fix the issue. I hope they all made it out alive. Some SQLing & log checking later, I found the problem and was able to fix it.

I had recently upgraded Magento from Enterprise 1.9.1.1 to 1.11.2.0, which included a number of minor and major updates. Somewhere in-between versions, the URL Rewrites data was modified to replace NULL values in the product_id and category_id fields with “0”. When indexing the later version of Magento, these zeroes are unable to be indexed as there is no product/category with ID “0”. The indexing process therefore fails, and leaves you hanging. To check if you have the same issue as me, run this command on SQL:


SELECT * FROM core_url_rewrite WHERE product_id = 0 OR category_id = 0;

If that statement yields any results, the solution is an easy one. Run this SQL on your database:


UPDATE core_url_rewrite SET core_url_rewrite.product_id = NULL WHERE core_url_rewrite.product_id = 0;

Rebuild your indexes, and if your problem was the same as mine, your issue should be fixed.

Tagged , , , , ,