3
votes

I've used the SQL scripts at this link to remove all test product data and categories. I've then read the category 'Products' and then imported my CSV file, which Magento says is fine when checking the data, but when I click import I am receiving the following error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (gare6221_qshed/catalog_product_website, CONSTRAINT FK_CAT_PRD_WS_PRD_ID_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY (product_id) REFERENCES catalog_product_entity (entity_id) ON DELETE CASCADE )

Any ideas guys? I'm really struggling with this one.

Thanks

3

3 Answers

4
votes

This has been fixed and the problem was due to SKU lengths being above 64 characters.

0
votes

First thing I would say is to avoid doing things directly with the database. It can get messy really quick (as you are learning).

Having said that, it looks like you may have some leftover data somewhere. Perhaps catalog_product_website?

0
votes

Experiencing this issue as well, though SKU's don't seem to be the cause (our SKUS are in the format of 'FOO-####'), so none of them are anywhere near 64 characters.

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

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

After selecting import, however, I receive 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 listings, it does seem as though the file was uploaded, as all my data was updated, so not entirely sure what's going on.