I added two categories with sub-categories from my ERP with an integration.

When I want to edit a category, I have an error "Unique constraint violation found".

Do you know how I can resolve this issue?

enter image description here


[code][2018-02-20 14:05:21] main.CRITICAL: Unique constraint violation found {"exception":"[object] (Magento\Framework\Exception\AlreadyExistsException(code: 0): Unique constraint violation found at /home/magento/www/vendor/magento/framework/EntityManager/Operation/Update.php:121, Magento\Framework\DB\Adapter\DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'infusion-low-temp-curing/Rubber.html-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT INTO url_rewrite (`redirect_ty.. [/code]

  • Are you editing or adding a new category?
    – Greg
    Commented Feb 20, 2018 at 13:46
  • Check your logs there should be more information about the constraint violated Commented Feb 20, 2018 at 13:55

2 Answers 2


The error log says that you are trying to do another insert with the same combination of columns that belong to URL_REWRITE table. The table is defied as UNIQUE and is not allowing same combination to be inserted twice.

  • Thanks. Do you know why the system triy to do another insert with the same combination when I want to save a modification on an existing category?
    – VP1354
    Commented Feb 20, 2018 at 15:01
  • I had a very similar problem before, however, it was happening when customer tried to place an order and order could not be created because it it trying to assign an already existing order number (which has to be unique too). It happened because of customer session not being closed after purchase for some reason. I fixed it by deleting the entry in the corresponding table and since then everything is running as it should.
    – Greg
    Commented Feb 20, 2018 at 15:09
  • If that helped you resolve the issue please mark the answer as accepted.
    – Greg
    Commented Feb 20, 2018 at 16:08
  • @BareFeet i have a similar issue here to your one: magento.stackexchange.com/questions/220833/… I was wondering if you could take a look and see if it is acutally the same and shine some light on which table you deleted entries from?
    – harri
    Commented Apr 4, 2018 at 13:23

I also experienced this issue when attempting to enable / disable categories on my website.

After investigation I found that the URL Key for the category was the root cause of my issue. For example "Tumble Dryers" was saving into the URL_Rewrite table as "Tumble Dryers.html".

I then went back through the categories in the URL_Rewrite change and changed the URLs to be in the following format "tumble-dryers.html". After this I attempted the change again via the Admin panel which then saved without the error.

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.