問題描述
我們的 magento 1.6.2 不能重新索引產品平面數據.它有時還會顯示重新索引過程出現問題".
我從其他用戶的經驗中嘗試了許多解決方案.沒有結果.我們進口了大宗產品,但我們不確定這是重新索引問題的原因.
理想的解決方案是什么?
這是我在shell中使用的命令:
php/usr/local/lsws/fcgi-bin/lsphp5/home/user/domains/my domain../public_html/shell/indexer.php
這是異常日志中的錯誤
2012-08-09T14:55:43+00:00 DEBUG (7):異常消息:SQLSTATE[23000]:完整性約束違規:1452無法添加或更新子行:外鍵約束失敗(`galagearbox/#sql-1662_1fc419`,約束`FK_CAT_PRD_FLAT_4_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_TEELE`) ON CA D跟蹤:#0/home/corecolu/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)#1/home/corecolu/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)#2/home/corecolu/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)#3/home/corecolu/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)#4/home/corecolu/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)#5/home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)#6/home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(327): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')#7/home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2548): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')#8/home/corecolu/public_html/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/home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(4)#10/home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()#11/home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()#12/home/corecolu/public_html/app/code/core/Mage/Index/Model/Process.php(207): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()#13/home/corecolu/public_html/app/code/core/Mage/Index/Model/Process.php(253): Mage_Index_Model_Process->reindexAll()#14/home/corecolu/public_html/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php(124): Mage_Index_Model_Process->reindexEverything()#15/home/corecolu/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Index_Adminhtml_ProcessController->reindexProcessAction()#16/home/corecolu/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('reindexProcess')#17/home/corecolu/public_html/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/corecolu/public_html/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()#19/home/corecolu/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)#20/home/corecolu/public_html/index.php(83): Mage::run('', 'store')#21 {主要}
在 Magento 中重新索引錯誤可能有很多原因,所以恐怕永遠不會有一個理想"的解決方案涵蓋所有可能的錯誤.
由于您發布了非技術性錯誤消息,我猜您已經嘗試使用管理后端重新索引產品平面數據并在那里看到錯誤消息.
我建議再次嘗試重新索引,但這次使用 shell/indexer.php
:
/usr/bin/php -f/abs/path/to/shell/indexer.php -- --reindex catalog_product_flat
這樣,如果重新索引失敗,您將獲得更有意義的技術錯誤消息.
這是一個列表,顯示了哪個參數用于哪個索引:
catalog_product_attribute 產品屬性catalog_product_price 產品價格catalog_url 目錄 URL 重寫catalog_product_flat 產品平面數據catalog_category_flat 類別平面數據catalog_category_product 分類產品catalogsearch_fulltext 目錄搜索索引cataloginventory_stock 庫存狀態tag_summary 標簽聚合數據
更新
您在帖子中添加的例外表明,
catalog_product_flat_4.entity_id
和
catalog_product_entity.entity_id
發現已損壞.
通常這意味著某些記錄在 catalog_product_entity.entity_id
字段中包含 null
,它們應該包含現有的 entity_id
代碼>s.
在嘗試解決此問題之前,請先備份您的數據庫.
現在,要查找損壞的記錄,請使用以下命令查詢您的數據庫:
SELECTa.entity_id從catalog_product_flat_4 作為左加入catalog_product_entity AS b ON a.entity_id = b.entity_id在哪里ISNULL(b.entity_id)
本次查詢找到的entity_id
是catalog_product_flat_4
表中的entity_id
,已損壞,需要刪除.>
刪除catalog_product_flat_4
中的相應記錄,然后再次嘗試重新索引.
Our magento 1.6.2 cant not reindex product flat data. It also sometimes shows 'There was a problem with reindexing process.'
I tried many solutions from the experience of other users. No result. We imported bulk products but we are not sure it's the cause of reindexing problem.
What could be the ideal solutions?
This is the command i used in shell:
php /usr/local/lsws/fcgi-bin/lsphp5 /home/user/domains/my domain../public_html/shell/indexer.php
This is the error from exception.log
2012-08-09T14:55:43+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`galagearbox/#sql-1662_1fc419`, CONSTRAINT `FK_CAT_PRD_FLAT_4_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCA)
Trace: #0 /home/corecolu/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/corecolu/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/corecolu/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/corecolu/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /home/corecolu/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(327): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /home/corecolu/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2548): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /home/corecolu/public_html/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 /home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(4)
#10 /home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /home/corecolu/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /home/corecolu/public_html/app/code/core/Mage/Index/Model/Process.php(207): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /home/corecolu/public_html/app/code/core/Mage/Index/Model/Process.php(253): Mage_Index_Model_Process->reindexAll()
#14 /home/corecolu/public_html/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php(124): Mage_Index_Model_Process->reindexEverything()
#15 /home/corecolu/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Index_Adminhtml_ProcessController->reindexProcessAction()
#16 /home/corecolu/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('reindexProcess')
#17 /home/corecolu/public_html/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/corecolu/public_html/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#19 /home/corecolu/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#20 /home/corecolu/public_html/index.php(83): Mage::run('', 'store')
#21 {main}
Reindexing errors in Magento can have many reasons, so I'm afraid there never will be an "ideal" solution covering all possible errors.
Since you've posted a non-technical error message, I guess you've tried to reindex the product flat data using the admin backend and saw the error message there.
I'd recommend to try to reindex again, but using the shell/indexer.php
this time:
/usr/bin/php -f /abs/path/to/shell/indexer.php -- --reindex catalog_product_flat
This way you'll get more meaningful technical error messages, if reindexing fails.
Here's a list that shows which parameter to use for which index:
catalog_product_attribute Product Attributes
catalog_product_price Product Prices
catalog_url Catalog URL Rewrites
catalog_product_flat Product Flat Data
catalog_category_flat Category Flat Data
catalog_category_product Category Products
catalogsearch_fulltext Catalog Search Index
cataloginventory_stock Stock Status
tag_summary Tag Aggregation Data
UPDATE
The exception you've added to your post tells, that the referential integrity between
catalog_product_flat_4.entity_id
and
catalog_product_entity.entity_id
was found being corrupted.
Usually this means some record(s) contain(s) null
in the field catalog_product_entity.entity_id
, where they are expected to contain existing entity_id
s.
Before trying to fix this, please backup your database first.
Now, to find the corrupted record(s), query your database with:
SELECT
a.entity_id
FROM
catalog_product_flat_4 AS a
LEFT JOIN
catalog_product_entity AS b ON a.entity_id = b.entity_id
WHERE
ISNULL(b.entity_id)
The entity_id
s found by this query are entity_id
s in the table catalog_product_flat_4
, which are corrupted and need to be deleted.
Delete the appropriate records in catalog_product_flat_4
, and then try to reindex again.
這篇關于Magento 1.6.2 不能重新索引產品平面數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!