Skip to content

Import products 2.4.6-p1 error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key

We did an upgrade from version 2.4.3 to the version 2.4.6-p1 and we started to have a problem on cloud environments (production and staging, but mostly on production) but not locally.

So, the steps to reproduce are being these:

  1. Go to System > Import page, select product and Add/Update.

  2. Click on upload button and select the csv (simple csv with 7 simple products and 7 grouped products). I get an error: “The source file moving process failed” enter image description here

  3. Refresh the page

  4. Do all again, the error “The source file moving process failed” doesn’t show up anymore.

  5. Click in Check Data

  6. Upload

  7. The error of the image( General system exception happened: Integrity constraint violation… shows up). >SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails [At this moment, all products are being created but with not data, only sku) Issue error message

  8. Try import again, same steps

  9. Now there is success and all products have their info populated. enter image description here

This is an annoying issue cause it’s happening only on production and sometimes on staging but never on local environments.

We have tried a few things like:

  • Create new admin users
  • Validated all csv fields including website_id, websites, etc…
  • Enabled old media gallery admin option (to solve the “The source file moving process failed” issue)
  • Checked the disk space of all nodes 5 – Checked all special characters on csv (There is no special characters)
  • I also checked the constraints, there is no duplicate keys.