Magento – Foreignkey integrity error while configurable product import magento 2

configurable-productimportexportmagento2product-attribute

When I was trying to import some configurable products, magento admin shows 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 
(`magento2`.`catalog_product_website`, CONSTRAINT `CAT_PRD_WS_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE), query was: INSERT INTO `catalog_product_website` (`product_id`,`website_id`) VALUES (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?) ON DUPLICATE KEY UPDATE `product_id` = VALUES(`product_id`), `website_id` = VALUES(`website_id`)

But the configurable product csv successfully passed the first validation check in the admin (Check data button). But when we click the import in next step, the above error is showing.

But the product information is inserted in the "catalog_product_entity" table. When I check the product detail page in admin, the configurable product variations are not listing and that product is not listing in store view.

Best Answer

I was able to solve this problem by shortening my SKUs. I had many that were over the 64 character limit imposed by the database schema and shortening them allowed for a successful import.

It is worth mentioning that the Data Checker does not currently (Oct. 2018) check for SKU length.

Related Topic