2

I am experiencing an issue which not sure why when I try to reindex it gives the error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 
'4458-142-1-1293-4458' for key 'PRIMARY', query was: INSERT INTO 
`catalog_product_index_eav_temp` 
(`entity_id`,`attribute_id`,`store_id`,`value`,`source_id`) VALUES (?, 
?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, 
?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, 
?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?).....

Now the problem is I don't see a table in the Database called catalog_product_index_eav_temp otherwise I would delete the duplicate entry and problem would be solved.

The line that is failing is with EAV:

php bin/magento indexer:reindex Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:00 Category Products index has been rebuilt successfully in 00:00:00 Product Categories index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:07

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 
'4458-142-1-1293-4458' for key 'PRIMARY', query was: INSERT INTO 
`catalog_product_index_eav_temp` 
(`entity_id`,`attribute_id`,`store_id`,`value`,`source_id`) VALUES (?, 
?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, 
?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, 
?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?).....

Stock index has been rebuilt successfully in 00:00:00 Catalog Search index has been rebuilt successfully in 00:00:01 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00

Does anyone know what could be wrong and how to fix! txs.

  • Anyone any help? possible a duplicate magento.stackexchange.com/questions/216720/… – Juliano Vargas May 23 '18 at 16:22
  • 1
    I am facing the exact same problem. The error only occurs after importing products via custom script using models. After deleting all products I created a product manually for testing and there are no issues. So I assume there ist something in my import. I keep digging... – omsta Nov 1 '18 at 16:50
  • @omsta if it helps I have found out that there were duplicate entry in catalog_product_entity_varchar and it was added via API So: SELECT * FROM catalog_product_entity_varchar WHERE value='4458,4458' AND attribute_id= 142\G; This showed me exactly what I need to see so in my case even deleting the product did not work for me. – Juliano Vargas Nov 2 '18 at 9:37
  • 1
    I just found my mistake. When setting the values for multiselect options (e.g. 123,124,125), I had multiple duplicates (123,123,124,125,125 and so on). A simple array_unique in the importer solved my issue. So always make sure each option value only appears once. – omsta Nov 2 '18 at 10:55
  • @omsta Yes that is correct. which file did you add array_unique? share the it please! – Juliano Vargas Nov 2 '18 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.