Magento 2: Resolving "Item with the same ID already exists" (Error) Print

  • M2
  • 0

Issue:

When logged in as a customer in Magento, and adding an item to your wishlist, or moving an item from your cart to the wishlist, you may encounter the error "Item (Magento\Wishlist\Model\Item\Interceptor) with the same ID already exists."

This error typically indicates a duplicate entry in the database or an issue related to caching or indexing.

In this KB article, we'll outline two possible solutions to resolve this error.

Solution 1: Remove Duplicate Entries in the Database

  1. Backup your database before making any changes to ensure you can revert to the previous state if something goes wrong.
  2. Access your Magento database using a database management tool like phpMyAdmin or a similar application.
  3. Locate the wishlist_item table in your Magento database.
  4. Look for any duplicate entries with the same wishlist_item_id value. If you find two or more rows with the same ID, delete one of the duplicate rows, leaving only one entry.
  5. Save the changes and close the database management tool.
  6. Clear the Magento cache by running the following command in the Magento root directory via SSH:

    php bin/magento cache:clean
  7. Test your website to see if the error is resolved.

Solution 2: Clear Cache and Reindex

If there's only one entry in the database and the error persists, follow these steps:

  1. Clear the Magento cache by running the following command in the Magento root directory via SSH:

    php bin/magento cache:clean
  2. Clear and regenerate the compiled code and dependency injection configuration by running these commands in the Magento root directory via SSH:

    php bin/magento setup:di:compile
    php bin/magento setup:upgrade
  3. Reindex Magento by running the following command in the Magento root directory via SSH:

    php bin/magento indexer:reindex
  4. If you're using a caching system like Redis, Varnish, or another caching service, clear the cache for those systems as well.
  5. Check your website again to see if the error is resolved.

 

If you are a Create Hosting customer utilising our MageVPS Plan, feel free to submit a support ticket and we can investigate and take care of this issue for you.


Was this answer helpful?

« Back