2011-11-13 16 views
0

サイトをバージョン1.4.0.1からバージョン1.6にアップグレードしました。 私はウェブサイトからすべての製品を削除し、正常に終了した「すべて再インデックスする」ことをしました。 私はこのエラーを取得する新製品を作成しようと再び再インデックスを行うよりも時:バージョン1.6にアップグレードした後、新しい製品のインデックスを再作成することはできません。

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 (`.../catalog_product_index_eav`, CONSTRAINT `FK_CAT_PRD_IDX_EAV_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CAS)' in .../lib/Zend/Db/Statement/Pdo.php:228 

私はTRUNCATE TABLE catalog_product_index_eavに試みたが、それは助けにはなりませんでした。

どうすればこの問題を解決できますか?

+1

あなたがやってメジャーアップグレードとすべての製品を削除している場合、新たに開始し、顧客をインポートする方が簡単かもしれません。 – clockworkgeek

+0

私は多くのコスチューム属性とCMSコンテンツを持っており、コピーには長い時間がかかります。悲しいことに、magentoがこの情報のエクスポートとインポートを提供するようには見えません。 – Shani1351

答えて

0

ライブサイトでこれを実行している場合は、おそらくApacheをオフにしてコマンドラインから再インデックスプロセスを実行する必要があります。

http://overlycaffeinated.com/2011/02/when-reindexing-in-magento-fails-use-the-command-line/

これは、これを行う方法について説明します。

+0

私はすべての製品を削除した後に作成したテスト製品が1つだけの開発環境で、コマンドラインから再インデックスプロセスを実行しています。 – Shani1351

0

次のクエリを使用してカタログテーブルをクリーンアップしました。

delete from `catalog_category_product` WHERE product_id not in(select entity_id from catalog_product_entity) 

delete from `catalog_category_product` WHERE category_id not in(select entity_id from catalog_category_entity) 

delete from ` catalog_product_website` WHERE product_id not in(select entity_id from catalog_product_entity) 

delete from ` catalog_product_entity_media_gallery` WHERE entity_id not in(select entity_id from catalog_product_entity) 

delete from ` catalog_product_index_eav_idx` WHERE entity_id not in(select entity_id from catalog_product_entity) 

delete from ` catalog_product_index_eav` WHERE entity_id not in(select entity_id from catalog_product_entity) 

delete from ` catalog_product_link` WHERE product_id not in(select entity_id from catalog_product_entity) 

delete from ` catalog_product_relation` WHERE parent_id not in(select entity_id from catalog_product_entity) 

これ以降、管理パネルから再インデックスできました。

+0

これは店舗からライブデータを削除するのですか? –

+0

SQLクエリでは、「テキストを削除するか、製品が主製品テーブルに存在しない番号を削除します」というメッセージが表示されるので、データを削除しますが、インデックスを作成するときに制約が発生する可能性があります。腕や脚が身体なしで浮かぶようなもの。それらのものを取り除くことができます。 – JaseC

15

これは、存在しないはずの不正なデータだけを削除します。

それは掘削のいくつかの時間を節約することとして、私は上記を拡大してきました:

delete FROM `catalog_product_entity_datetime` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_decimal` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_gallery` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_group_price` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_int` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_media_gallery` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_text` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_tier_price` where entity_id not in (select entity_id from catalog_product_entity); 
delete FROM `catalog_product_entity_varchar` where entity_id not in (select entity_id from catalog_product_entity); 
#originals with formatting fixed: 
delete from `catalog_category_product` WHERE product_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_category_product` WHERE category_id not in(select entity_id from catalog_category_entity); 
delete from `catalog_product_website` WHERE product_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_index_eav_idx` WHERE entity_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_index_eav` WHERE entity_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_link` WHERE product_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_relation` WHERE parent_id not in(select entity_id from catalog_product_entity); 
+1

はこれも 'PF1をDELETE FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID制約エラーのために役立ちます私を見つけた。* catalog_product_flat_1のPF1 FROM LEFT JOINのcatalog_product_entity P ON pf1.entity_id = p.entity_id ISNULL(p.entity_id)' – JaseC

+0

これは私が探していたものであるWHERE長い間。ありがとう! – Ross

関連する問題