【问题标题】:Magento Catalog Product indexing error during Enterprise to Community downgrade企业到社区降级期间的 Magento 目录产品索引错误
【发布时间】:2014-02-13 22:03:53
【问题描述】:

我们正在尝试从 Magento EE 1.13 降级到 CE 1.8.1。

我们正在使用新的 CE 代码库,但尝试使用相同的数据库,我们认为这应该可以从以下主题中实现: https://magento.stackexchange.com/questions/6706/how-to-migrate-from-enterprise-edition-to-community-edition

在删除我们发现的任何企业参考后,该网站运行良好,但我们无法解决的一个错误是索引错误:

exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magentodb`.`catalog_category_product_index`, CONSTRAINT `FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DE)' in /mnt/hgfs/public/lib/Zend/Db/Statement/Pdo.php:228

搜索此错误的大部分结果都建议尝试在 catalog_category_product 表中查找对不存在产品的引用,考虑到外键约束失败,这是有道理的:

SELECT * FROM `catalog_category_product` WHERE 
product_id not in (select entity_id from catalog_product_entity);
SELECT * FROM `catalog_category_product` WHERE 
category_id not in (select entity_id from catalog_category_entity);

但是这些查询返回空集 - 似乎没有任何对实体表中不存在的 entity_ids 的引用。

关于这可能来自哪里的任何建议?

【问题讨论】:

    标签: mysql magento indexing


    【解决方案1】:
    1. 转到 PhpMyAdmin 并运行以下查询:

      ALTER TABLE catalog_category_product_index 删除外键 FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID

    2. 从 Magento 管理面板或 CLI 运行重新索引;

    3. 重建索引完成后,从 PhpMyAdmin 运行此查询:

      catalog_category_product_index 删除 product_id 不在(从 catalog_product_entity 中选择 entity_id); ALTER TABLE catalog_category_product_index 添加约束 FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID 外键 (product_id) 引用 catalog_product_entity (entity_id) ON DELETE CASCADE ON UPDATE CASCADE;

    【讨论】:

      【解决方案2】:

      重读那个错误。仔细

      exception 'PDOException' with message 
      'SQLSTATE[23000]: Integrity constraint violation: 
      1452 Cannot add or update a child row: a foreign key constraint fails
      (   `magentodb`.`catalog_category_product_index`, 
          CONSTRAINT `FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID` 
      
          FOREIGN KEY (`product_id`) 
              REFERENCES `catalog_product_entity` (`entity_id`) ON DE)'
      

      特别是他们引用表格的部分

      `magentodb`.`catalog_category_product_index`, 
      

      当索引代码尝试插入或更新catalog_category_product_index 中的列时,外键约束失败。我会检查这张桌子是否也很干净。

      【讨论】:

        【解决方案3】:

        带有消息的异常“PDOException”

        'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magentodb`.`catalog_category_product_index`, CONSTRAINT `FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DE)' in /mnt/hgfs/public/lib/Zend/Db/Statement/Pdo.php:228
        

        对于这个错误,我得到了解决方案。查看以下信息

        以下是我们用于解决类别产品重新索引问题(索引类别/产品关联)的过程:

        1. 登录 phpMyAdmin
        2. 转到catalog_category_product_index
        3. 单击“导出”。
        4. 仅导出启用了“禁用外键检查”的结构。
        5. 掉表catalog_category_product_index
        6. 使用导出的 SQL,删除 出口的底部。请务必保留“SET FOREIGN_KEY_CHECKS” 陈述。
        7. 点击“SQL”,粘贴修改后的SQL,点击“Go”
        8. 登录 Magento 后端
        9. 转到:系统 -> 索引管理
        10. 点击“类别产品”索引旁边的“重新索引数据”

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-05-26
          • 2018-01-04
          • 1970-01-01
          • 1970-01-01
          • 2023-03-31
          • 2011-07-12
          相关资源
          最近更新 更多