The error “UNQ_SALES_FLAT_ORDER_INCREMENT_ID” is usually seen when magento uses alphanumeric order numbers. When the old customer buys a product again, magento instead of increasing the ordre increment from the latest order, increases the increment from the last order of the same old customer. This creates a duplicate entry and magento refuses to take an order.
You can also receive an email containing “SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘AB100082765’ for key ‘UNQ_SALES_FLAT_ORDER_INCREMENT_ID‘” error or “There was an error processing your request” during placing an order.
There is an easy fix to this problem. It requires a core modification of a code which can be done if you have access to ftp credentials. It cannot be performed from backend.
[alert variation=”alert-error”]BACKUP YOUR DATABASE FIRST. I’M NOT RESPONSIBLE FOR ANYTHING THAT HAPPENS WITH THE FOLLOWING PROCESS. USE IT AT YOUR OWN RISK[/alert]
Open the ftp channel and Go to
app/code/core/Mage/Sales/Model/Resource/Quote.php
Find:
isOrderIncrementIdUsed
There at its bottom you will find a line and you will have to replace it with another code (just remove a part of code)
Replace
$bind = array(':increment_id' => (int)$orderIncrementId);
with
$bind = array(':increment_id' => $orderIncrementId);
Save it.
[signoff icon=”icon-thumbs-up”]Now the alphanumeric order will start working again.[/signoff]
5 comments
it works . thank you
Perfect solution, many thanks!
Hey,
Have u ever solved this?
I had the same error code. the increment number and the last order number are not synchronize anymore. what we did is the following:
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.\†(in my install it is 24)
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.)
Hope that this helps.
Perfect .. solved it perfectly .. thank you 🙂
Thank you very much