0

When importing about 12000 rows of products from a .csv file, it suddenly gives me the following error:

General system exception happened Additional data: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kumpla01_mg1.mg_catalog_product_website, CONSTRAINT MG_CAT_PRD_WS_PRD_ID_MG_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY (product_id) REFERENCES mg_catalog_product_entity (entity_id) ON DELETE), query was: INSERT INTO mg_catalog_product_website (product_id,website_id) VALUES (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?) ON DUPLICATE KEY UPDATE product_id = VALUES(product_id), website_id = VALUES(website_id)


This is the inside of the database (It always throws it at the same line, the .csv file should be just fine as 4299 rows were not causing any problems, and I am using a specific algorithm to generate them. I will still paste some more details, if it helps whoever will contribute to this problem.

mg_catalog_product_website (website_id from the SQL error, reaches 4300) mg_catalog_product_website

mg_catalog_product_entity (entity_id, as you can see, it somehow reaches 4400) mg_catalog_product_entity

As said before, csv file is all fine, I do know import is kinda shady based on past issues, but I hope we can find the fix. I tried deleting and truncating all the product tables, but the issue still happened. It must be something with the code, also my csv contains all the possible attributes. This is my first ever post, please be patient with me, I'm barely an amateur.

  • Edit) It always happens at specific points. When I imported the certain line 4301 and so on as the only line in the csv file, it went thru up until about 7700. Why does it happen at these specific lines? If I remove these lines (as if they were causing the problems) it still doesn't solve it. Another edit. If I upload the SAME file again, it goes thru without a problem. – Florjan Oct 8 '19 at 15:41
0

Alright, simplifying the SKU value of every element did the trick.

| improve this answer | |

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.