1

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.

  • Please have a look on eav_attribute table – aman Jan 16 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. – Rahul Singh Jan 16 at 6:59
  • 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 ? – garyconstable Jan 16 at 8:32
0

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:
// 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;
    }

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.