2014-02-18 67 views
0

在重新索引產品屬性在Magento 1.7.0.2,我們得到以下錯誤:Magento的1.7.0.2重建索引產品屬性錯誤

Product Attributes 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 (`xxdbnamexx`.`mage_catalog_product_index_eav`, CONSTRAINT `FK_CAT_PRD_IDX_EAV_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `mage_catalog_product_entity` (`entity_id)' in /home/xxxxxxxxx/public_html/lib/Zend/Db/Statement/Pdo.php:228 
Stack trace: 
#0 /home/xxxxxxxxx/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) 
#1 /home/xxxxxxxxx/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) 
#2 /home/xxxxxxxxx/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) 
#3 /home/xxxxxxxxx/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) 
#4 /home/xxxxxxxxx/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ma...', Array) 
#5 /home/xxxxxxxxx/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ma...', Array) 
#6 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(179): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ma...') 
#7 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Resource/Helper/Mysql4.php(48): Mage_Index_Model_Resource_Abstract->insertFromSelect(Object(Varien_Db_Select), 'mage_catalog_pr...', Array, false) 
#8 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(153): Mage_Index_Model_Resource_Helper_Mysql4->insertData(Object(Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source), Object(Varien_Db_Select), 'mage_catalog_pr...', Array, false) 
#9 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(113): Mage_Index_Model_Resource_Abstract->insertFromTable('mage_catalog_pr...', 'mage_catalog_pr...', false) 
#10 /home/xxxxxxxxx/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Abstract.php(54): Mage_Index_Model_Resource_Abstract->syncData() 
#11 /home/xxxxxxxxx/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav.php(185): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract->reindexAll() 
#12 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Eav->reindexAll() 
#13 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Index_Model_Indexer_Abstract->reindexAll() 
#14 /home/xxxxxxxxx/public_html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll() 
#15 /home/xxxxxxxxx/public_html/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything() 
#16 /home/xxxxxxxxx/public_html/shell/indexer.php(198): Mage_Shell_Compiler->run() 
#17 {main} 

任何人都可以提供任何幫助?

回答

0

錯誤消息顯示您正在嘗試執行的操作違反了mage_catalog_product_index_eavmage_catalog_product_entity之間的外鍵約束。

這意味着您的mage_catalog_product_index_eav表中的entity_ids不在mage_catalog_product_entity表中發生。這可能是因爲mage_catalog_product_entity中的某些entity_id爲空。

也可能是因爲mage_catalog_product_index_eav試圖引用的記錄根本沒有。在這種情況下,您可以從mage_catalog_product_index_eav中刪除引用記錄。

無論如何,你將不得不弄清楚違規記錄是什麼。查看Magento 1.6.2 cant not reindex product flat data的第一個回答,瞭解如何做到這一點。 (這不是完全相同的問題,因爲他們處理平面數據,但仍然有用,我認爲。)

+0

嗨,感謝您的幫助。試圖運行下面的查詢並返回任何結果:'SELECT a.entity_id FROM mage_catalog_product_index_eav AS一個 LEFT JOIN mage_catalog_product_entity AS B關於a.entity_id = b.entity_id WHERE ISNULL(b.entity_id)' –

+0

後一更好地看看你的錯誤,我意識到這是由_inserting_ entity_ids引入'mage_catalog_product_index_eav'。所以,索引器似乎試圖在不存在的產品的索引表中創建記錄。 看看用戶olivenet在這裏做了什麼:http://www.magentocommerce.com/boards/viewthread/265847/#t376030它的要點是,您暫時從'mage_catalog_product_index_eav'中刪除外鍵約束。 (完成後別忘了放回去!)然後再次運行索引器。現在,你應該能夠找到「問題產品」。 – Pixelkracht