【发布时间】:2014-03-25 14:22:07
【问题描述】:
现在我正在为 Magento 产品、类别和属性集编写自定义导入脚本。我知道使用裸 MySQL 和 PHP 是不好的做法,但目前就是这样。
使用我的自定义函数创建产品时,此错误出现在第一个产品上:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]:
Integrity constraint violation: 1452 Cannot add or update a child row:
a foreign key
constraint fails (`shopname`.`cataloginventory_stock_status`, CONSTRAINT
`FK_CATINV_STOCK_STS_STOCK_ID_CATINV_STOCK_STOCK_ID` FOREIGN KEY (`stock_id`)
REFERENCES `cataloginventory_stock` (`stock_id`) ON DE)' in
/www/lib/Zend/Db/Statement/Pdo.php:228
Stack trace: #0 /www/lib/Zend/Db/Statement/Pdo.php(228):
PDOStatement->execute(Array) #1
/www/lib/Varien/Db/Statement/Pdo/Mysql.php(110):
Zend_Db_Statement_Pdo->_execute(Array) #2
/www/app/code/core/Zend/Db/Statement.php(291):
Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3
/www/lib/Zend/Db/Adapter/Abstract.php(479):
Zend_Db_Statement->execute(Array) #4
/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(238):
Zend_Db_Adapter_Abstract->q in
/www/lib/Zend/Db/Statement/Pdo.php on line 234
我查看了堆栈溢出,但找不到适合“cataloginventory_stock_status”错误的任何内容。
这可能是之前删除数据集的一些剩余数据吗?
你们能澄清一下这个具体的错误是什么吗?
【问题讨论】:
标签: mysql magento import foreign-keys constraints