SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry - Magento 2

Entry key '4639-168-1-283-4639', where 4639 is product_id, 168 is attribute_id, 1 is store_id, 283 is attribute_value_id for which is getting this issue.

So if suppose attribute 168 type is varchar, then its values will be in catalog_product_entity_varchar.

Now search for attribute 168 along with entity_id 4639, you can see there is some values in 'value' column.

Edit that row, you will see there is more than 1 entry (comma separated) for same value_id (here 283), just remove all other duplicates values from there and save it.

Flush cache and re-run index command.

If error comes again then again (that may come for other products as well) check and fix in similar way.

Not sure why magento puts duplicate values for multi-select.

Tags:

Php

Cron

Magento2