Magento 1.7无法重新索引产品单位数据...尝试重新索引数据库时出现以下错误。
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`d014505f`.<result 2 when explaining filename '#sql-1f6c_39a11d'>, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`e)' in /www/htdocs/w00f5624/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:#0 /www/htdocs/w00f5624/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement- >execute(Array)
#1 /www/htdocs/w00f5624/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /www/htdocs/w00f5624/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /www/htdocs/w00f5624/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /www/htdocs/w00f5624/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /www/htdocs/w00f5624/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
#9 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)
#10 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /www/htdocs/w00f5624/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /www/htdocs/w00f5624/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /www/htdocs/w00f5624/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#14 /www/htdocs/w00f5624/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()
#15 /www/htdocs/w00f5624/shell/indexer.php(198): Mage_Shell_Compiler->run()
#16 {main}
最佳答案
magento以编程方式重新索引
ID Code
1 catalog_product_attribute
2 catalog_product_price
3 catalog_url
4 catalog_product_flat
5 catalog_category_flat
6 catalog_category_product
7 catalogsearch_stock
8 cataloginventory_stock
9 tag_summary
for ($i = 1; $i <= 9; $i++) {
$process = Mage::getModel('index/process')->load($i);
$process->reindexAll();
}