Item (MagentoCatalogModelCategoryInterceptor) with the same ID already exists

5.14K 浏览开发笔记

Item (MagentoCatalogModelCategoryInterceptor) with the same ID already exists

m2里,后台修改分类后,发现前台报错

1 exception(s): Exception #0 (Exception): Item (MagentoCatalogModelCategoryInterceptor) with the same ID "6" already exists

具体原因是url_rewrite表里的重复了。根据分类id,找到多余的,删掉就行了

如果分类很多的话,直接删除url_rewrite里的category记录,再reindex

delete from url_rewrite where entity_type = 'category'
php bin/magento indexer:reindex

还需要重建下category的url rewrite。不然的话会直接显示view/id这样的。

需要借助第三方插件.

https://github.com/olegkoval/magento2-regenerate_url_rewrites

这个插件在2.3.0里有问题,慎用

或者这个插件

https://github.com/karliuka/m2.IndexerUrlRewrite

在2.3.0里用没问题,推荐用

最后于 4月前 被admin编辑 ,原因:
0