Magento
Now Reading
[SOLVED] UNQ_SALES_FLAT_ORDER_INCREMENT_ID in Magento
5

[SOLVED] UNQ_SALES_FLAT_ORDER_INCREMENT_ID in Magento

by UmarApril 13, 2014

The errorUNQ_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.

 magentologo

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.

BACKUP YOUR DATABASE FIRST. I’M NOT RESPONSIBLE FOR ANYTHING THAT HAPPENS WITH THE FOLLOWING PROCESS. USE IT AT YOUR OWN RISK

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.

Now the alphanumeric order will start working again.

What's your reaction?
Love It
0%
Interested
100%
WTF
0%
Wink
0%
Sad
0%
Angry
0%
Whatever
0%
Me No Like
0%
About The Author
Umar
Umar
Umar is a technological freak. He is very much into gadgets and games. Blogging is his hobby.
  • Jack
    April 18, 2014 at 6:06 pm

    it works . thank you

  • Marc
    June 13, 2014 at 2:29 pm

    Perfect solution, many thanks!

  • Vishal Sanwar
    July 12, 2014 at 7:04 am

    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.

  • Chief
    December 6, 2014 at 9:44 pm

    Perfect .. solved it perfectly .. thank you 🙂

  • May 24, 2016 at 11:40 am

    Thank you very much

Leave a Reply to Chief Cancel reply