Magento 2.4.1升级至2.4.5 Commerce后出现重新索引问题
解决Magento产品扁平索引报错:Unknown column 'row_id' in 'field list'
执行bin/magento indexer:reindex catalog_product_flat时触发SQL错误,提示catalog_product_entity表缺少row_id字段,同时数据库中不存在临时表catalog_product_entity_tmp_indexer,可按以下步骤解决:
给
catalog_product_entity表添加row_id字段
直接在数据库中执行SQL:ALTER TABLE `catalog_product_entity` ADD COLUMN `row_id` INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`row_id`);注:操作前建议备份表数据,避免意外。
手动创建缺失的临时索引表
运行以下SQL创建catalog_product_entity_tmp_indexer表:CREATE TABLE `catalog_product_entity_tmp_indexer` ( `row_id` int UNSIGNED NOT NULL, `entity_id` int UNSIGNED NOT NULL, `type_id` varchar(32) NOT NULL, `attribute_set_id` smallint UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `has_options` smallint UNSIGNED NOT NULL DEFAULT '0', `required_options` smallint UNSIGNED NOT NULL DEFAULT '0', `sku` varchar(64) DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`row_id`), KEY `CATALOG_PRODUCT_ENTITY_TMP_INDEXER_ENTITY_ID` (`entity_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;重置索引状态并重试
先重置索引状态:bin/magento indexer:reset catalog_product_flat然后重新执行重索引:
bin/magento indexer:reindex catalog_product_flat验证索引状态
运行命令查看索引是否正常:bin/magento indexer:status确认
catalog_product_flat的状态为Ready即可。
内容的提问来源于stack exchange,提问作者pavani
相关产品推荐
相关产品推荐

