Magento 2 – Unique Constraint Violation Found on Product Save

magento2

While saving new product in admin panel I am getting this error "Unique constraint violation found"

Exception Log of this error:

Unique constraint violation found {"exception":"[object]
(Magento\Framework\Exception\AlreadyExistsException(code: 0):
Unique constraint violation found at
/chroot/home/hannahha/esto.co.uk/html/shop/vendor/magento/framework/EntityManager/Operation/Create.php:134,
Magento\Framework\DB\Adapter\DuplicateException(code: 1062):
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'4294967295' for key 'PRIMARY', query was: INSERT INTO
catalog_product_entity (entity_id, attribute_set_id, type_id,
sku, has_options, required_options, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)

Best Answer

After a lot of debugging I found the issue, I had and custom module in which I was injecting some custom functionality on the observer "catalog_product save_commit_after", which have some bug and was crashing. Due to which this error was occurring.

To fix this, I removed the bug from my custom module and after this I opened the "catalog_product_entity" table in phpmyadmin and removed the the record with the key mentioned in the exception error.

This fixed my issue.

Related Topic