Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000001' for key 'UNQ_SALES_FLAT_ORDER_IN

Tags:

mysql

magento

I have installed Magento 1.9.0.1 and I am live since 1 month. The first order of a Client worked without Problem. But now following error message appears when the order should be processed "There was an error processing your order. Please contact us or try again later."

Log file says: exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000001' for key 'UNQ_SALES_FLAT_ORDER_INCREMENT_ID'' in /home/www/web81/html/lib/Zend/Db/Statement/Pdo.php:228

I have read a lot of threads and also used Google but could not find a solution. I am a beginner and the shop should work tomorrow again :-( I very much appreciate your help!

Thanks a lot for your help & best regards

like image 252
MODELCARSHOP Avatar asked Dec 04 '14 20:12

MODELCARSHOP


2 Answers

You can try following.

In app/code/core/Mage/Sales/Model/Resource/Quote.php

Search for isOrderIncrementIdUsed method

In that method,

replace

$bind = array(':increment_id' => (int)$orderIncrementId);

with

$bind = array(':increment_id' => $orderIncrementId);

------------------------------------------------------------ OR-------------------------------------------------------------------------------

Go to admin->sales-> orders and look up the highest order number (for each store view!)

Then look at your database. In the table eav_entity_type you will find all entity types listed. The one of interest to change is where the order number starts, ie. order sales/order. Remember the entity_type_id.

Next go to the table eav_entity_store. Look up the entity_type_id. Now you can change the value of increment_last_id to your last actual order number. (That is, if you wanted to have your next orderId to be 15000 set increment_last_id to 14999.)

like image 185
Emipro Technologies Pvt. Ltd. Avatar answered Oct 05 '22 05:10

Emipro Technologies Pvt. Ltd.


Try this solution. This would definitely help you.

The order number 100000001 (i.e. increment ID or increment_id) already exists in your order table, sales_flat_order, and it's failing the order save when someone checks out because increment_ids must be unique.

First, verify that you have these order numbers you see in the error messages are indeed already present in the sales_flat_order.increment column. Then, you need to modify the eav_entity_store.increment_id value(s), so that new increment IDs will never overlap with your the already existing order numbers.

Check the maximum value in sales_flat_order.increment_id, and update eav_entity_store.increment_id with a value greater than that.

like image 33
Makwana Ketan Avatar answered Oct 05 '22 04:10

Makwana Ketan