SQLSTATE [23000]: Integrity constraint violation: 1452 Unable to add or update child row: foreign key constraint is not fulfilled

I used the SQL scripts on this link to delete all data and categories of test products. Then I read the Products section and then imported my CSV file, which Magento says is ok when checking data, but when I click on import, I get the following error:

SQLSTATE [23000]: Violation of integrity constraint: 1452 Unable to add or update child row: foreign key constraint is not satisfied ( gare6221_qshed/catalog_product_website, CONSTRAINT FK_CAT_PRD_WS_PRD_ID_CAT_PRD_ENTT_ENTT_IDFOREIGN KEY ( product_id) LINKS catalog_product_entity( entity_id) ENABLE CASCADE)

Any ideas guys? I really struggle with that.

thank

+3
source share
3 answers

This has been fixed and the problem is that the SKU is longer than 64 characters.

+3
source

The first thing I would say is to avoid actions directly with the database. It can be very dirty (as you study).

Having said that, it looks like you might have some remaining data. Perhaps product_website_directory?

0
source

Also experiencing this problem, although SKU does not seem to be the cause (our SKUS is in the format "FOO - ####"), so none of them contain about 64 characters.

When I select the csv file and select the check data, it passes the verification penalty:

Checked rows: 1718, checked entities: 47, invalid rows: 0, total errors: 0
File is valid! To start import process press "Import" button

After choosing the import, I get this error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magentoss`.`catalog_product_option_type_value`, CONSTRAINT `FK_CAT_PRD_OPT_TYPE_VAL_OPT_ID_CAT_PRD_OPT_OPT_ID` FOREIGN KEY (`option_id`) REFERENCES `catalog_product_option` (`option_id`) ON D), query was: INSERT INTO `catalog_product_option_type_value` (`option_type_id`,`sort_order`,`sku`,`option_id`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)

After checking the product lists, it seems that the file has been downloaded, since all my data has been updated, so I’m not quite sure what is happening.

0
source

All Articles