4

I'm trying to setup my crons for Magento 2.2.2, but nothing seems to be updating.

I have created cron in cPanel, like below, each once per minute:

/usr/local/bin/php /home/userishere/public_html/bin/magento cron:run | awk '{ print strftime("\%Y-\%m-\%d \%H:\%M:\%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.log

/usr/local/bin/php /home/userishere/public_html/update/cron.php | awk '{ print strftime("\%Y-\%m-\%d \%H:\%M:\%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.log

/usr/local/bin/php /home/userishere/public_html/bin/magento setup:cron:run | awk '{ print strftime("\%Y-\%m-\%d \%H:\%M:\%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.log

I check the scheduale in PhpMyAdmin to see this:

cron

Error:

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

Any ideas where I'm going wrong? If you need more info please let me know.

  • This error means that one row that you try to insert has an PK which already exists in db, did you restore this db recently? – lpFranz Mar 9 '18 at 13:39
  • No I have not restored it, how do I find out which row? Thank you :) – MyStackExchange Mar 9 '18 at 14:07
  • Error has updated to this SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4639-168-1-283-4639' for key 'PRIMARY', query was: INSERT INTO catalog_product_index_eav_temp (entity_id,attribute_id,store_id,value,source_id) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), – MyStackExchange Mar 9 '18 at 14:16
  • @MyStackExchange did Find what was the issue? I started to have this issue as well. – Juliano Vargas Mar 28 '18 at 14:38
  • Hello guys, i getting same issue with : search_tmp_5af6c92069db99_50693483. did you find any solution ? – Camit1dk Jul 2 '18 at 12:52
15

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.

  • 1
    thank this is absolute right I updated entries with duplicatuion values like ` value_id: 239750 attribute_id: 152 store_id: 0 entity_id: 2540 value: 3671,3671` Once I remove the duplicate value reindex started working again! – Juliano Vargas Aug 1 '18 at 14:42
  • Wow. Thank you dev_67Commerce. I was trying to figure this out for so many time. Your explanation was priceless. – SilverStoreS Nov 5 at 9:49
  • Thanks to show me the light! For others I have prepared a simple script to solve the issue: gist.github.com/shinesoftware/9df5c706fd5c9161c36297b2509eba33 – Michelangelo Nov 12 at 17:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.