2012-04-19 101 views
3

我已使用此link處的SQL腳本刪除所有測試產品數據和類別。然後我讀過類「產品」,然後輸入我的CSV文件,檢查數據時的Magento說是好的,但是當我點擊導入我收到以下錯誤:SQLSTATE [23000]:完整性約束違規:1452無法添加或更新子行:外鍵約束失敗

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)

任何想法的傢伙?我真的很苦惱這個。

感謝

回答

3

這已被修復,問題是由於SKU長度超​​過64個字符。

+0

與我一起工作除了我有一個產品與空SKU。 – 2018-01-21 19:20:28

0

第一件事,我想說的是,以避免直接與數據庫做的事情。它可以很快得到凌亂(正如你正在學習的那樣)。

話雖如此,看起來你可能有一些剩餘的數據。也許catalog_product_website?

+0

嘿,謝謝你的回覆。事實證明,這是爲了處理CSV中的一些SKU超過64個字符長。 一個完整的cPanel備份還原後,我離開舊數據並試圖導入並得到相同的錯誤。當我減少提到的SKU的時候,它就起作用了。因此,未來將考慮一些事情。 – 2012-04-21 15:35:51

+0

哇。永遠不會有這樣的期望。好東西與大家分享。 – 2012-04-21 18:19:51

0

雖然SKU似乎不是原因(我們的SKUS格式爲'FOO - ####'),所以它們都不會接近64個字符,所以也會遇到此問題。

當我選擇CSV文件,並選擇檢查數據,它通過細檢查:

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

選擇導入後,但是,我收到此錯誤:

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 (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?) 

檢查後的產品看起來好像該文件已上傳,因爲我的所有數據都已更新,因此不完全確定發生了什麼。

相關問題