Answer the question
In order to leave comments, you need to log in
How to fix SQL error?
Hello! When adding a product in the OpenCart admin panel, an error pops up from the database.
Fatal error: Uncaught exception 'Exception' with message 'Error: Duplicate entry '400-74' for key 'PRIMARY'<br />Error No: 1062<br />INSERT INTO oc_product_to_store SET product_id = '400', store_id = '74'' in /var/www/u0430319/data/www/siimple.ru/system/library/db/mysqli.php:40 Stack trace: #0 /var/www/u0430319/data/www/siimple.ru/system/library/db.php(45): DB\MySQLi->query('INSERT INTO oc_...') #1 /var/www/u0430319/data/www/storage/modification/admin/model/catalog/product.php(18): DB->query('INSERT INTO oc_...') #2 [internal function]: ModelCatalogProduct->addProduct(Array) #3 /var/www/u0430319/data/www/storage/modification/system/engine/loader.php(248): call_user_func_array(Array, Array) #4 [internal function]: Loader->{closure}(Array, Array) #5 /var/www/u0430319/data/www/siimple.ru/system/engine/proxy.php(47): call_user_func_array(Object(Closure), Array) #6 /var/www/u0430319/data/www/storage/modification/admin/controller/catalog/product.php(52): Proxy->__call('addProduct', Array) #7 /var/www/u0430319/data/www/storage/m in /var/www/u0430319/data/www/siimple.ru/system/library/db/mysqli.php on line 40
Answer the question
In order to leave comments, you need to log in
It seems that product_id and store_id were set as PRIMARY KEY when creating the table, which means that they must be unique. This error indicates that there is already a record with the values product_id = '400', store_id = '74'.
Such decisions can help:
1. To change PRIMARY KEY for the table.
2. Do not try to insert a duplicate as you are doing now
3. Use replace again
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question