1

When I'm updating products in my Magento-store externally from my accounting software I'm receiving following error in the logs:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '727-0-4-0'
for key 'CC12C83765B562314470A24F2BDD0F36', query was: INSERT INTO
`catalog_product_entity_group_price` (`entity_id`, `all_groups`,
`customer_group_id`, `value`, `website_id`) VALUES (?, ?, ?, ?, ?)

How do I fix this?

user2002046
  • 63
  • 1
  • 8
  • Do you have a unique constraint on the `catalog_product_entity_group_price` table? Follow [this link](http://stackoverflow.com/questions/5094948/mysql-how-can-i-see-all-constraints-on-a-table) to see how you can figure what constraints are there. – Tim Biegeleisen Jan 27 '16 at 08:27

1 Answers1

2

Whenever there is an issue related to "SQL Integrity constraint", I have tried doing the below and this has worked for me very well:

Each time, you plan to update products using Magento Admin Panel or Another source in Magento.

Magento Enterprise Edition

Navigate to System > Configuration > Advanced > Index Management > Index Options > Set all the options to "Update when scheduled"

Magento Community Edition

Navigate to System > Index Management > Select all > Actions > Change Index Mode > Manual Update > Save

These settings are to avoid any SQL Integrity Constraint errors during Bulk/Single Product Updates.

After products are updated, revert the changes back as below:

Magento Enterprise Edition

Navigate to System > Configuration > Advanced > Index Management > Index Options > Set all the options to "Update on Save" > Save

Magento Community Edition

Navigate to System > Index Management > Select all > Actions > Change Index Mode > Update on Save > Save

Note :: Make sure the /var/locks is removed before setting these and before doing a bulk product update.

Let me know if this helps.

Happy Coding...

Shivani
  • 526
  • 2
  • 5
  • Thanks for your thorough answer. I ended up installing an Asynchronous Re-indexing extension, that re-index via cron and not on events. This has helped. In this regard your answer makes great sense. https://mirasvit.com/magento-extensions/magento-asynchronous-reindex.html – user2002046 Aug 03 '16 at 14:46