Sometimes while doing a Reindex in the Admin Panel you will get the error “An error occurred while saving the URL rewrite.” Now, while there are numerous fixes to this issue, I found one that I felt best addressed the issue and corrected it quickly with minimal effort.
If you tried to reindex any of the other index’s past Catalog URL Rewrites, those will fail as well, but do not confuse those not indexing with the Catalog URL Rewrite. If you try to reindex those separately they will still work as the issue only lies with Catalog URL Rewrites.
Now to fix this issue you will need to truncate your core_url_rewrite table.
To truncate the core_url_rewrite table without getting this bunk Magento error, take the following steps.
- To access the table, open either your SVN or Terminal depending on which OS you are on.
- Once you’re in, you will need to SSH into your development or production box and “cd /user/bin/”
- Log into mysql “mysql -u username -p password.”
- Show all the current databases “show databases;”
- Now you should only have the one database for your website, but if this is on a Dev or Local environment, you will have multiple databases.
- Once you have figured out which database you need to use by checking the local.xml, use the following command in mysql “use db_name;” where db_name is the name of the database you want to change.
- Now that you are in the correct database you are having the issues with you will want to run this command “truncate core_url_rewrite;”
- To check that it worked run this command “select count(*) from core_url_rewrite;” it should come back that it is 0.
- Now go into the admin panel and reindex your Catalog URL Rewrites. At this point, it should work without an error.
- If you want to be extra-sure it worked, you can go back to your Terminal or SVN and go back to the sql table and run the “select count(*) from core_url_rewrite;”. This time it should return a much higher number then 0.
That’s all it takes to fix the Catalog URL Rewrite index error in the admin.