I have a store running (updated from a clean install of 1.6). The store keeps running into the "An error occurred while saving the URL rewrite" error.

The store is a very simple installation with only premium matrix rate installed as an additional module.


On trying to refresh the Catalog URL Rewrites the following error occurs: "An error occurred while saving the URL rewrite"

Attempts to fix:

  1. recursively chown entire store directory to correct user
  2. recursively chmod 777 var and media
  3. clear var/session, var/cache, var/locks
  4. Backup and truncate core_url_rewrite (resolves or a short time) but less than ideal due to indexing issues on renamed products and future use of custom rewrites

Checking the logs the errors that are being generated are along the following lines:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'category-name/sub-category-1' for key 'UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID'

UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID belongs to core_url_rewrite and is a UNIQUE KEY across the store_id and request_path.

The duplicate value in question doesn't actually exist in the request_path however multiple instances of request_path/store_id duplicates seem to be in the database.

Example of a duplicate entry:

INSERT INTO `core_url_rewrite` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`, `options`, `description`)
    (5246, 1, 376, NULL, 'category/376', 'test-assemblies/123-assemblies', 'catalog/category/view/id/376', 1, NULL, NULL),
    (6334, 1, 376, NULL, 'category/376', 'test-assemblies/123-assemblies', 'catalog/category/view/id/376', 1, NULL, NULL);


  1. Would it be safe for me to go through and remove all duplicate entries and potentially resolve the issue?
  2. What could be happening to allow duplicate entries to occur?
  3. Can anyone shed any light on the issue?

Update: seems to be an issue with categories not product looking further into the issue.

3 Answers 3


Your questions answered

Would it be safe for me to go through and remove all duplicate entries and potentially resolve the issue?

If you mean edit the DB directly. No. Never. Ever.

What could be happening to allow duplicate entries to occur?

It can be a number of things; but it will naturally happen from time to time.

Can anyone shed any light on the issue?


The fix

The fix is very simple actually. Where you see the error

Duplicate entry for product ID XXX

  1. Change all indexes in Admin > System > Index Management to be Update-On-Save

  2. Open Admin > Catalogue > Manage Products - filter the grid by product ID above - then edit the product.

  3. Hit save on the product edit page

This usually rectifies 99% of Duplicate entry errors for products. Try and run the mass failed index from before to confirm. You can then change your index actions back to whatever they were previously.

  • Hi Sonassi, Thanks for the input but unfortunately the issue doesn't seem to be along the lines you mentioned. The Indexes are set to Update-On-Save. After further investigation the current issue is category related not product. If the code/core is correct and error handling is sufficient this should never happen. At the moment it isn't failing gracefully it's causing an issue that cannot be resolved within the standard magento functionality.
    – John Nzime
    Feb 7, 2013 at 17:39
  • @JohnNzime - the same fix applies to categories as it does to products. Just edit the respective category (with the ID shown in the error) and save it via the admin. The fix isn't to set the indexes to "Update on Save" - it is to set the indexes to "Updates on Save" and then save the entity (category/product) via the Magento admin. Feb 7, 2013 at 17:57
  • I've tried going through every category/sub category related to the re-writes referenced in the error and still the same result and the same problem. The main issue is the value/key it's saying is a duplicate doesn't exist...
    – John Nzime
    Feb 7, 2013 at 18:13
  • @JohnNzime - you don't need to go through every category or subcategory. You need to save the SPECIFIC category/product with the ID defined in the error. You may have many errors, in which case, you just need to keep repeating the process with each broken Category/Product respectively. Feb 7, 2013 at 18:15
  • The issue is category/category not product category. When saving the category causing the issue in hand and it had not effect, I went though the parent category and sub categories just to be sure. As I said the erroring key category/category-1 request_path doesn't exist.
    – John Nzime
    Feb 7, 2013 at 18:27

I was able to solve the above by looking for the SQL error in the log (as described), and deleting the duplicate entry for the product in the Catalog > URL Rewrite Management section.

Once the duplicate entry was removed, the reindex worked fine & the error was cleared.


Maybe it is has to do something with the upgrade from 1.6. Can you compare your shop with a fresh install on all the files and the database structure. I wanted to post this as a comment but i dont have enough reputation yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.