magento 2: Getting Error Unique constraint violation found – When remove suffix .html

  • Open
  • Shiwani
    Participant
    August 14, 2019 at 12:49 pm #2577
    Shiwani

    Hi All

    I Am getting error when I am removing .html from Category URL Suffix. Error is Unique constraint violation found.

    Anyone have genuine solution for this.

    Thanks

  1. Pankaj Sharma
    Participant
    Posts: 144
    August 16, 2019 at 11:06 am #2596
    Pankaj Sharma

    Hi Shiwani,

    This issue can be due to the duplicate entries for the products and categories. If there are URLs already saved in url_rewrite table you need to remove these entries. You can check and remove entries from table url_rewrite.

    I hope it will work for you.

    Thanks

    • This reply was modified 3 months, 3 weeks ago by Pankaj Sharma Pankaj Sharma.
  2. sandeep
    Keymaster
    Posts: 1
    November 17, 2019 at 11:59 am #4186

    This can be caused by duplicate entries for the same product in url_rewrite database table.

    You can follow the below steps to solve this issue:

    Backup your current Magento2 database
    Delete all records from table url_rewrite. You can run the following SQL command:

    DELETE FROM url_rewrite WHERE entity_type = ‘product’;
    Login to your Magento 2 backend
    Re-save all your Categories

    or

     

    regenerate url_rewrites again by using this

    https://github.com/olegkoval/magento2-regenerate_url_rewrites

    Clean the Magento2 cache
    Now, you should be able to save/update the Product URL Suffix in the Configuration Settings.