重新索引数据时出错了。我已经工作了大约3天,这个问题仍然无法找到解决方案。这是我收到的日志错误:
默认值(MANAdev)索引进程未知错误:异常 带有消息'SQLSTATE [23000]的'PDOException':完整性约束 违规:1452无法添加或更新子行:外键 约束失败(
glasseso_magento
。m_filter2_value
,CONSTRAINTFK_m_filter2_value_mana_db?edit_session
外国钥匙 (edit_session_id
)REFERENCESm_edit_session
(id
)ON DELETE CASCADE ON UPDATE CASCAD)'in /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Statement/Pdo.php:228
堆栈追踪:
#0 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /Applications/MAMP/htdocs/magestore/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `m_...', Array)
#5 /Applications/MAMP/htdocs/magestore/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `m_...', Array)
#6 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `m_...', Array)
#7 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('m_filter2_value', Array)
#8 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mana_Filters_Model_Filter2_Value))
#9 /Applications/MAMP/htdocs/magestore/app/code/local/Mana/Db/Helper/Data.php(217): Mage_Core_Model_Abstract->save()
#10 /Applications/MAMP/htdocs/magestore/app/code/local/Mana/Db/Model/Indexer.php(36): Mana_Db_Helper_Data->replicate()
#11 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Index/Model/Process.php(209): Mana_Db_Model_Indexer->reindexAll()
#12 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#13 /Applications/MAMP/htdocs/magestore/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()
#14 /Applications/MAMP/htdocs/magestore/shell/indexer.php(198): Mage_Shell_Compiler->run()
#15 {main}
下一个例外
'Zend_Db_Statement_Exception',消息为'SQLSTATE [23000]:完整性 约束违规:1452无法添加或更新子行:异类 键约束失败(
glasseso_magento
。m_filter2_value
,CONSTRAINTFK_m_filter2_value_mana_db?edit_session
外国钥匙 (edit_session_id
)REFERENCESm_edit_session
(id
)ON DELETE CASCADE ON UPDATE CASCAD)'in /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Statement/Pdo.php:234
堆栈追踪:
#0 /Applications/MAMP/htdocs/magestore/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `m_...', Array)
#4 /Applications/MAMP/htdocs/magestore/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `m_...', Array)
#5 /Applications/MAMP/htdocs/magestore/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `m_...', Array)
#6 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('m_filter2_value', Array)
#7 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mana_Filters_Model_Filter2_Value))
#8 /Applications/MAMP/htdocs/magestore/app/code/local/Mana/Db/Helper/Data.php(217): Mage_Core_Model_Abstract->save()
#9 /Applications/MAMP/htdocs/magestore/app/code/local/Mana/Db/Model/Indexer.php(36): Mana_Db_Helper_Data->replicate()
#10 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Index/Model/Process.php(209): Mana_Db_Model_Indexer->reindexAll()
#11 /Applications/MAMP/htdocs/magestore/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#12 /Applications/MAMP/htdocs/magestore/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()
#13 /Applications/MAMP/htdocs/magestore/shell/indexer.php(198): Mage_Shell_Compiler->run()
#14 {main}
希望有人能在这个问题上帮助我。
答案 0 :(得分:2)
我看了一下m_edit_session的内容,只有一行ID为1,时间戳在created_at下。我改变了那个的ID,只将行改为0(而不是1),这个错误就消失了。
答案 1 :(得分:1)
一个好的解决方案可能是禁用"外键检查"。在文件/app/code/local/Mana/Db/Helper/Data.php(217)...
改变这个:
$object->save();
为此:
$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$writeConnection->query("SET FOREIGN_KEY_CHECKS = 0;");
$object->save();
$writeConnection->query("SET FOREIGN_KEY_CHECKS = 1;");
祝你好运!
答案 2 :(得分:0)
快速解决方案是捕获异常并记录它,以便索引器完成其工作。
也许try {} catch {} Block适合这里:
Applications / MAMP / htdocs / magestore / app / code / local / Mana / Db / Helper / Data.php(217):Mage_Core_Model_Abstract-> save()
可能在Mana-Module的不一致实现中发现异常的原因。