cancel
Showing results for 
Search instead for 
Did you mean: 

Item with the same ID already exists.

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Item with the same ID already exists.

I am on Magento CE 2.2.6 and I am starting to see this error more and more on my products making it impossible to edit them.

 

Item (Magento\Catalog\Model\Product\Interceptor) with the same ID "419" already exists.

 

How do I fix the products with this error code and how do I stop this from happening?

 

 

5 REPLIES 5

Re: Item with the same ID already exists.

Hello @Goad 

 

are you using enterprise edition of magento? 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Item with the same ID already exists.

No, as stated I am on CE 2.2.6

Re: Item with the same ID already exists.

Hello @Goad 

 

it happen if same entry into exist into catalog_product_entity or some other table

 

vendor/magento/framework/Data/Collection.php

 

 

public function addItem(\Magento\Framework\DataObject $item)
    {
        $itemId = $this->_getItemId($item);

        if ($itemId !== null) {
            if (isset($this->_items[$itemId])) {
                throw new \Exception(
                    'Item (' . get_class($item) . ') with the same ID "' . $item->getId() . '" already exists.'
                );
            }
            $this->_items[$itemId] = $item;
        } else {
            $this->_addItem($item);
        }
        return $this;
    }

into thrown 

if (isset($this->_items[$itemId])) {
echo $itemId;exit;
                throw new \Exception(
                    'Item (' . get_class($item) . ') with the same ID "' . $item->getId() . '" already exists.'
                );
            }

by using you will get itemId that contain such an issue

 

hope it will help you.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Item with the same ID already exists.

I think a lot of what you are saying is lost in translation.

 

Are you saying I should modify my collection.php? If so, can you be a bit more clear what needs to be changed?

Re: Item with the same ID already exists.

@Goad 

 

i give the file name and debug which product id create issue

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer