I know there is a similar issue regarding a product, but now I've got this error with a category.

I can't recall that I did something different, it just all of a sudden started throwing this error as soon as I got on a category page on the frontend.

Sometimes re-saving the category in the admin resolved the issue, but most of the times it doesn't. Where does this error come from? How to fix it? Did anyone else encounter this error too?


It looks like the category page asks the URL rewrite table for the URL's. It generates this query:

SELECT `e`.*, 
   IF(at_is_active.value_id > 0, at_is_active.value, 
   at_is_active_default.value) AS 
FROM   `catalog_category_entity` AS `e` 
   INNER JOIN `catalog_category_entity_int` AS `at_is_active_default` 
           ON ( `at_is_active_default`.`entity_id` = `e`.`entity_id`) 
              AND ( `at_is_active_default`.`attribute_id` = '46' ) 
              AND `at_is_active_default`.`store_id` = 0 
   LEFT JOIN `catalog_category_entity_int` AS `at_is_active` 
          ON ( `at_is_active`.`entity_id` = `e`.`entity_id` ) 
             AND ( `at_is_active`.`attribute_id` = '46' ) 
             AND ( `at_is_active`.`store_id` = 1 ) 
   LEFT JOIN `url_rewrite` 
          ON ( url_rewrite.entity_id = e.entity_id ) 
             AND ( url_rewrite.is_autogenerated = 1 
                   AND url_rewrite.store_id = 1 
                   AND url_rewrite.entity_type = 'category' ) 
WHERE  ( IF(at_is_active.value_id > 0, at_is_active.value,   
            '1' ) 
   AND ( `e`.`entity_id` IN( '10', '170', '171', '172', 
                             '173', '175', '176', '177', 
                             '178', '179', '180', '189', '276' ) ) 
ORDER  BY `e`.`position` ASC 

But if your url_rewrite-table is corrupted (which is most likely in my case), it ends up with having duplicate ID's.

  • 2
    Sometimes re-saving the category in the admin resolved the issue This worked for me, Thanks!! – nuwaus Jun 14 '17 at 15:22
  • 3
    I have the same issue, but re-saveing the category doesn't help. – Oliver Schmid Jun 28 '17 at 6:23
  • Someone found a fix? I'm having the same issue, for me it is strange. Have 10 stores created in wich only 3 stores and 1 is the default store, the catalog page works but in the others stores it does not. I have set up that the home page was a catalog page – Gianni Di Falco Jan 5 '18 at 13:03
  • Solution : magento.stackexchange.com/questions/121021/… – Rahul Dec 18 '19 at 7:31
  1. Delete records from 'url_rewrite' table where "entity_type" is "category".
  2. run php bin/magento indexer:reindex
  • It have 3000 record, so i've to truncate the table to make this work :( – fudu Feb 1 '19 at 3:09
  1. Go to Admin Panel > Marketing > URL Rewrites.
  2. Filter by "category/{entity_id} (which causes the already exist error)" in the targer_path. If you find same target_path for same store then delete the one.
  3. Run php bin/magento indexer:reindex

The following SQL query cleans up duplicate category rewrites. Do not use without a backup.

You can use n98-magerun2 db:console or any other mysql client:

  from url_rewrite
  where url_rewrite_id in (
    select url_rewrite_id
    FROM (select url_rewrite_id
      from url_rewrite
      where entity_type = 'category'
      group by target_path, store_id
      having count(*) > 1) t

For us just running this did the trick:

php bin/magento indexer:reindex

Our error (with Magento 2.2.2) was this when doing frontend search or entering category:

Exception #0 (Exception): Item (Magento\Catalog\Model\Product\Interceptor) with the same ID "XXXX" already exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.