Magento (Item (Mage_Catalog_Model_Product) with the same id "nnnnnn" already exist)

Magento (Item (Mage_Catalog_Model_Product) with the same id "nnnnnn" already exist)

July 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento (Item (Mage_Catalog_Model_Product) with the same id "nnnnnn" already exist)

Magento: Resolving Duplicate Product Issues

Dear developer,

The Problem at Hand

You’ve encountered an error message in your Magento installation that reads “Item (Mage_Catalog_Model_Product) with the same id ‘nnnnnn’ already exist.” This issue arises due to the presence of duplicate products, likely created during a recent CSV import using the data profiler. Let me guide you through identifying and eliminating these duplicates.

Understanding the Cause

The error occurs because Magento’s EAV (Entity Attribute Value) model doesn’t allow for multiple products sharing the same SKU or ID. When you imported a CSV file containing updated attribute data, it seems that instead of updating existing products, new duplicates were created, leading to this conflict.

Diagnosing the Issue

First, let’s confirm our suspicions about duplicate products. Open your Magento backend and navigate to Catalog > Manage Products. Search for one of the problematic SKUs or use a filter like “Status=Out of Stock” (if that was the original status). If you find multiple entries with the same SKU but different IDs, you’ve identified the duplicates.

Temporary Fix: Disabling the Error Message

While we work on a permanent solution, let’s temporarily disable the error message so your site can function normally. In your theme directory (app/design/frontend/{your_package}/{your_theme}/template/catalog/category/view.phtml), find this line:

<?php echo $this->getProductListHtml() ?>

Replace it with:

<?php echo $this->getProductListHtml()->setGroupByFilter(false) ?>

This removes the groupby clause causing the error, allowing your site to display products again. This is a quick fix, not a solution.

Permanent Resolution: Identifying and Removing Duplicates

Step 1: Finding Duplicate Products

Write a MySQL query to identify duplicate SKUs. Log into your database using a tool like phpMyAdmin or the command line, then run this query:

SELECT COUNT(*) AS Count, SKU FROM catalog_product_entity GROUP BY SKU HAVING Count > 1;

This will return all SKUs with more than one matching entry.

Step 2: Removing Duplicates

Before you delete any data, always backup your database! Once backed up, execute the following query to remove the duplicate products:

DELETE FROM catalog_product_entity WHERE entity_id IN (
    SELECT MIN(entity_id) FROM catalog_product_entity GROUP BY SKU HAVING COUNT(*) > 1
)

This SQL statement finds all minimum entity IDs (the first occurrence of each product) and deletes their corresponding duplicates.

Step 3: Updating the Product Table

After removing duplicates, you’ll need to update some fields in the catalog_product_entity table. Run these queries:

To update the SKU field for the remaining products:

UPDATE catalog_product_entity SET sku = CONCAT('dup_', entity_id) WHERE entity_id IN (
    SELECT MIN(entity_id) FROM catalog_product_entity GROUP BY SKU HAVING COUNT(*) > 1
);

This appends “dup_” to all product SKUs that were duplicates.

To update the attribute sets:

UPDATE eav_attribute SET attribution_set_id = (SELECT attribution_set_id FROM eav_attribute WHERE entity_type_id = 4 AND attribut_code = 'sku') WHERE eav_attribute.attribut_code LIKE '%_store%';

This ensures all attributes are linked to valid attribute sets.

Conclusion

Remember, always backup before making changes to your database. The SQL queries provided above will help you identify and remove duplicates from the catalog_product_entity table in Magento.

The key takeaways for future prevention:

  1. Ensure your CSV data is properly formatted before importing.
  2. Use the “Update existing products” option when possible during imports.
  3. Regularly check for duplicate products to prevent this issue from recurring.

If you need further assistance or find yourself struggling with similar Magento issues, feel free to reach out to our team at https://laravelcompany.com/contact-us. We’re always here to help!

Stay productive, The Laravel Company Team

Catalog Themes Admin Import/Export

Our network