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
, CONSTRAINTMG_CAT_PRD_WS_PRD_ID_MG_CAT_PRD_ENTT_ENTT_ID
FOREIGN KEY (product_id
) REFERENCESmg_catalog_product_entity
(entity_id
) ON DELETE), query was: INSERT INTOmg_catalog_product_website
(product_id
,website_id
) VALUES (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?) ON DUPLICATE KEY UPDATEproduct_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_entity (entity_id, as you can see, it somehow reaches 4400)
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.