0

最近,我们将选择的产品、客户、订单等从 Zen Cart 迁移到 Magento。第一次迁移完美无缺,索引很好,所以我们继续迁移所有产品等。迁移所有产品后,我们尝试运行各种重新索引,但出现错误。下面是错误日志。

Error:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`ecigexpr_newecx`.`cataloginventory_stock_status`, CONSTRAINT `FK_CATINV_STOCK_STS_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON)

2013-01-23T23:43:38+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`ecigexpr_newecx`.`cataloginventory_stock_status`, CONSTRAINT `FK_CATINV_STOCK_STS_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON)
Trace: #0 /home/ecigexpr/public_html/ecximproved/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/ecigexpr/public_html/ecximproved/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/ecigexpr/public_html/ecximproved/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/ecigexpr/public_html/ecximproved/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /home/ecigexpr/public_html/ecximproved/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Resource/Abstract.php(179): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#6 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Resource/Helper/Mysql4.php(48): Mage_Index_Model_Resource_Abstract->insertFromSelect(Object(Varien_Db_Select), 'cataloginventor...', Array, false)
#7 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Resource/Abstract.php(153): Mage_Index_Model_Resource_Helper_Mysql4->insertData(Object(Mage_CatalogInventory_Model_Resource_Indexer_Stock), Object(Varien_Db_Select), 'cataloginventor...', Array, false)
#8 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Resource/Abstract.php(113): Mage_Index_Model_Resource_Abstract->insertFromTable('cataloginventor...', 'cataloginventor...', false)
#9 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php(251): Mage_Index_Model_Resource_Abstract->syncData()
#10 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_CatalogInventory_Model_Resource_Indexer_Stock->reindexAll()
#11 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Process.php(209): Mage_Index_Model_Indexer_Abstract->reindexAll()
#12 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#13 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/Model/Process.php(249): Mage_Index_Model_Process->reindexEverything()
#14 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php(124): Mage_Index_Model_Process->reindexEverything()
#15 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Index_Adminhtml_ProcessController->reindexProcessAction()
#16 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('reindexProcess')
#17 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#18 /home/ecigexpr/public_html/ecximproved/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#19 /home/ecigexpr/public_html/ecximproved/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#20 /home/ecigexpr/public_html/ecximproved/index.php(89): Mage::run('', 'store')
#21 {main}

我可以清楚地看到问题出在 cataloginventory_stock_status 和 website_id 中,但不知道如何纠正它。任何帮助将不胜感激。

4

1 回答 1

0

我们永远找不到真正的解决方案,但我们最终转移到另一台服务器并安装了一个新的 magento 副本。然后我们在 phpmyadmin 中导入数据库,一切正常。由于数据库中的任何内容都没有改变,因此我相信可能是锁定文件、损坏或其他原因导致了文件方面的问题(而不是在数据库中)。如果您遇到这种情况,您可能需要先清除缓存和锁定文件,然后用备份覆盖。如果这不起作用,导出数据库,重新安装 magento 并导入数据库是我能想出的唯一解决方案。虽然不是最佳解决方案,但我们不再遇到问题。

于 2013-02-07T14:11:34.087 回答