3

I have this error,

1 exception(s):
Exception #0 (Exception): Item (Magento\Eav\Model\Entity\Attribute) with the same ID "87" already exists.

it seems to me that there must be a duplicate row ?

But what Table as I cant find one.

Thanks.

3
  • Please have a look on eav_attribute table Commented Jan 16, 2019 at 3:08
  • You need to go to database with table name, eav_attribute Now check field within this table and if duplicates row are exist one field need to delete. Commented Jan 16, 2019 at 6:59
  • 1
    I can see lots of rows with duplicate attribute codes but the duplicates have a unique entity id - so they dont look like duplicates to me ? Commented Jan 16, 2019 at 8:32

1 Answer 1

3

Some migration or system that populates the database which caused the duplication of IDs. Magento core predicts a data created by its self, so this kind of error could be solved without stopping the system but it was not implemented yet (e.g. Github issue in the reference session).

Solution

  • Recreate the attribute or remove the attribute
  • Change the attribute ID through the database
  • Create a core patch to skip attribute with error to not show or show it unfilled in the product page to edit as below (creating a module):
// file: 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;
    }
1
  • facing the same issue, Item (Magento\Eav\Model\Entity\Attribute) with the same ID "62" already exists. in vendor/magento/framework/Data/Collection.php:407 when i checked eav_attribute for id=62, it is special_from_date and there are no duplicate entries for id 62 can you suggest how can i resolve this ? as many tables have values coordinated with attribute 62 its not possible to remove it and recreate it. The code you show where you have commented the exception throw, is it safe to do that ? will there be any impact on functionality ? Commented Oct 15, 2022 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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