【问题标题】:Magento Product Flat Data Reindex causes errorMagento 产品平面数据重新索引导致错误
【发布时间】:2013-12-11 21:40:54
【问题描述】:

我无法重新索引产品平面数据,因为我收到以下错误:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`fpshop/#sql-6101_1484e`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CA)

有什么想法可以解决吗?

【问题讨论】:

标签: magento indexing


【解决方案1】:

转到您的数据库并检查表catalog_product_entitycatalog_product_flat_1 中的所有行,尤其是entity_id 列中的值。

很可能某些行缺少所需的值,这意味着要么有人弄乱了数据库,要么你正在使用一个模块,这弄乱了数据库。您要么需要删除那些损坏的行,要么用它们缺失的值填充它们。

修正提案:

为了解决这个问题,请尝试在下面运行查询以找到损坏的行:

SELECT a.entity_id FROM catalog_product_flat_1 AS a LEFT JOIN catalog_product_entity AS b ON a.entity_id = b.entity_id WHERE ISNULL(b.entity_id);

然后删除你做的那些行

DELETE FROM catalog_product_flat_1 where entity_id = '123456789';

其中123456789 是断行的ID。

【讨论】:

    【解决方案2】:

    您是否尝试过禁用 Flat_catalog_category 和 Flat_catlaog_product,然后截断 catalog_product_flat 表。请务必通过执行 SET FOREIGN_KEY_CHECKS = 0; 来禁用外键约束检查;在截断之前。一旦这样做,您应该能够通过 ssh 手动重新索引。一个有据可查的解决方案在这里:http://binarythoughts21.blogspot.in/2013/12/reindexing-problems-in-magento.html

    【讨论】:

      猜你喜欢
      • 2013-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 2023-03-31
      • 1970-01-01
      • 2019-09-30
      相关资源
      最近更新 更多