Magento- Article conditioning Error SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

Picture

For one of our clients, there was a an error if it tried new product / a new products create. This error was: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘485-1’ for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID’ .

This is a problem which enters the database, when trying to make a one-time re-entry. In this case, it is the database table cataloginventory_stock_item from the origin of the error. This problem can have many reasons: A botched database after a backup restoration, manual intervention, Article Imports etc.

Now if you took a look at the Magento backend, saw, that the final (unquenched!) Products in the product overview the ID 481 had. In o.g. But table entries were about the ID 500 available.

Now you can go into the database (phpMyAdmin) a first Backup the o.g. Make table and then run the following SQL command:

SELECT * Cataloginventory_stock_status `FROM` ORDER BY `product_id` DESC LIMIT 1

This shows the last assigned a product ID. In our case, this was also the 481. This we remember.

Now we give the following SQL command:

SELECT * FROM WHERE product_id cataloginventory_stock_item > 481;

This now shows us all assigned product IDs, greater, as our last ID 481 (“481” replace naturally through the unique ID!). These IDs, greater, delete.

Now the problem should be solved.

As always, we make no warranty to our instructions. This is done at your own risk and only with backup and best in a test system wise. For us, this approach has led to the desired result and a product system is now easily possible.

Used in Magento Version 1.6.2.0. Comments, Suggestions, Ask? Gladly!

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

2 comments on “Magento- Article conditioning Error SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry”

  1. I tried the same, but it didn’t work. I am able to add products successfully, but the integrity constraint error shows on top. Please advise.

Leave a Reply

Your email address will not be published. Required fields are marked *