我们正在重新索引我们的产品平面数据和我们在magento中的类别平面数据,我们正在获得完整性约束错误

时间:2013-11-17 09:25:17

标签: magento zend-framework e-commerce

通过SSH执行此操作时,我们收到了错误消息:

产品平面数据索引流程未知错误:

exception ‘PDOException’ with message ‘SQLSTATE[23000]: Integrity constraint vio lation: 1452 Cannot add or update a child row: a foreign key constraint fails (` db96761_final`.<result 2 when explaining filename ‘#sql-4d76_775b93’>, CONSTRAIN T `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REF ERENCES `catalog_product_entity)’ in /nfs/c06/h05/mnt/96761/domains/jumastudio.c om/html/lib/Zend/Db/Statement/Pdo.php:228 
Stack trace: 
#0 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Zend/Db/Statement/Pdo.  php(228): PDOStatement->execute(Array) 
#1 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Varien/Db/Statement/Pd o/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) 
#2 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Zend/Db/Statement.php( 300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) 
#3 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Zend/Db/Adapter/Abstra ct.php(479): Zend_Db_Statement->execute(Array) 
#4 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Zend/Db/Adapter/Pdo/Ab stract.php(238): Zend_Db_Adapter_Abstract->query(’ALTER TABLE `ca...’, Array) 
#5 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Varien/Db/Adapter/Pdo/ Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query(’ALTER TABLE `ca...’, Array) 
#6 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Varien/Db/Adapter/Pdo/ Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query(’ALTER TABLE `ca...’) 
#7 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/lib/Varien/Db/Adapter/Pdo/ Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query(’ALTER TABLE `ca...’) 
#8 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addF oreignKey(’FK_CAT_PRD_FLAT...’, ‘catalog_product...’, ‘entity_id’, ‘catalog_prod uct...’, ‘entity_id’, ‘CASCADE’, ‘CASCADE’) 
#9 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Prod uct_Flat_Indexer->prepareFlatTable(1) 
#10 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_ Indexer->reindexAll() 
#11 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer-> reindexAll() 
#12 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll() 
#13 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll() 
#14 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/shell/indexer.php(158): M age_Index_Model_Process->reindexEverything() 
#15 /nfs/c06/h05/mnt/96761/domains/jumastudio.com/html/shell/indexer.php(198): M age_Shell_Compiler->run() 
#16 {main}

1 个答案:

答案 0 :(得分:0)

好的,我终于想通了。显然magento存储catalog_product_flat表,并且不更新这些表中的内容。所以解决方案如下:

1)备份数据库

2)关闭Magento中的Use Flat Product和Category选项,并将Index模式从Product Flat Data切换到Manual update。

3)截断catalog_product_flat表

4)通过ssh重新索引:php shell / indexer.php --reindex catalog_product_flat