Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Magento update 1.5.1 > 1.6.1 ==> Duplicate ordernumber errors
 
TomvH
Jr. Member
 
Total Posts:  6
Joined:  2008-04-12
 

Hi all,

On my dev server, I’m trying to upgrade our 1.5.1 shop to 1.6.1.  The update itself goes well and the shop seems to work fine after the update.

After some more testing I found that existing customers, who already had placed an order before, are getting a message that the order cannot be completed when they want to finish the checkout process.

After some digging I found the following error in the exceptions log:

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'O110719' for key 'UNQ_SALES_FLAT_ORDER_INCREMENT_ID'' in /var/www/vhosts/***/httpdocs/lib/Zend/Db/Statement/Pdo.php:234
Stack trace
:
#0 /var/www/vhosts/***/httpdocs/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/vhosts/***/httpdocs/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/vhosts/***/httpdocs/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /var/www/vhosts/***/httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `j5...', Array)
#4 /var/www/vhosts/***/httpdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `j5...', Array)
#5 /var/www/vhosts/***/httpdocs/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `j5...', Array)
#6 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(448): Zend_Db_Adapter_Abstract->insert('sales_f...', Array)
#7 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php(425): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Order))
#8 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Sales_Model_Resource_Order_Abstract->save(Object(Mage_Sales_Model_Order))
#9 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#10 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Sales/Model/Service/Quote.php(189): Mage_Core_Model_Resource_Transaction->save()
#11 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote->submitOrder()
#12 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Checkout/Model/Type/Onepage.php(767): Mage_Sales_Model_Service_Quote->submitAll()
#13 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Checkout/controllers/OnepageController.php(501): Mage_Checkout_Model_Type_Onepage->saveOrder()
#14 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Checkout_OnepageController->saveOrderAction()
#15 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#16 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /var/www/vhosts/***/httpdocs/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#18 /var/www/vhosts/***/httpdocs/app/Mage.php(640): Mage_Core_Model_App->run(Array)#19 /var/www/vhosts/***/httpdocs/index.php(80): Mage::run('', 'store')
#20 {main}

It seems that magento wants to use the previous ordernumber of the customer to create the new order, which results in a duplicate entry.

I suspected some extensions so I disabled them before upgrading, no joy. 
Updated the extensions and then updated magento, no joy. 
Disabled the custom theme, no joy.

Anybody a clue on where to find the source of this problem?

processing the same order through magento backend seems to go fine, so i’ts only a frontent problem.

Thanks,

Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

You can try increasing your Increment number here

eav_entity_store

 
Magento Community Magento Community
Magento Community
Magento Community
 
TomvH
Jr. Member
 
Total Posts:  6
Joined:  2008-04-12
 
Brent W Peterson - 28 October 2011 08:32 AM

You can try increasing your Increment number here

eav_entity_store

I just checked this table but it seems to be ok.  Tried to increase the number and tried again but same error.

It seems that, in my case, magento only checks this table for new customers / customers first order:

Current increment id let’s say 57
Customer A has placed 3 orders, last order was 29
Customer B has placed 1 order, last order 51

New customer places order, everything goes well, gets ordernumber 58, increment goes to 58
Customer B places order, error: log shows magento wants to use order number 51, which, off course, is duplicate
Customer A places order, error: log shows magento wants to use order number 29. Again, exactly the same number as this customers last order and off course duplicate
Another new customer places order, no problem, this will get order number 59 and increment also increases to 59

Strange ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

Did you try increasing your increment_id by 1000?

 
Magento Community Magento Community
Magento Community
Magento Community
 
TomvH
Jr. Member
 
Total Posts:  6
Joined:  2008-04-12
 
Brent W Peterson - 30 October 2011 10:07 AM

Did you try increasing your increment_id by 1000?

Just tried, same error.  New customers get the increased order number.  Existing customers that already place an order before keep getting their last order number.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

@TomvH:: The problem is that the quoteId is reserved for customers who have already started an order. If you wanted to you could remove all the items from the quote’s and then the customer would not be able to order anything they had saved.

 
Magento Community Magento Community
Magento Community
Magento Community
 
TomvH
Jr. Member
 
Total Posts:  6
Joined:  2008-04-12
 
Brent W Peterson - 31 October 2011 11:25 AM

@TomvH:: The problem is that the quoteId is reserved for customers who have already started an order. If you wanted to you could remove all the items from the quote’s and then the customer would not be able to order anything they had saved.

Hi Brent,

Thanks again for your answer, but that also doesn’t seem to be the problem.  I just tried to upgrade again, but first I emptied the shopping carts of my test accounts if they had anything in it.

Same error all over again.  All the existing accounts but with no previous orders work fine, the others don’t.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zelphir
Jr. Member
 
Total Posts:  7
Joined:  2011-01-26
 

Hi, I have the same problem… have you solved it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
starnetwork
Sr. Member
 
Total Posts:  144
Joined:  2007-11-23
Israel
 

I also see this problem
any updates?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kedeesofttech
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2012-05-22
 

Yes i am having same problem it shows track like this

2012-06-12T14:05:51+00:00 ERR (3):
exception ‘PDOException’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1242’ for key ‘UNQ_SALES_FLAT_ORDER_INCREMENT_ID’’ in /public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(’INSERT INTO `sa...’, Array)
#5 /public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query(’INSERT INTO `sa...’, Array)
#6 /public_html/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query(’INSERT INTO `sa...’, Array)
#7 /public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert(’sales_flat_orde...’, Array)
#8 /public_html/app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php(425): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Order))
#9 /public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Sales_Model_Resource_Order_Abstract->save(Object(Mage_Sales_Model_Order))
#10 /public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#11 /public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(189): Mage_Core_Model_Resource_Transaction->save()
#12 /public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote->submitOrder()
#13 /public_html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(774): Mage_Sales_Model_Service_Quote->submitAll()
#14 /public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(511): Mage_Checkout_Model_Type_Onepage->saveOrder()
#15 /public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveOrderAction()
#16 /public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch(’saveOrder’)
#17 /public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#18 /public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#19 /public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#20 /public_html/index.php(90): Mage::run(’’, ‘store’)
#21 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
mpikounis
Member
 
Total Posts:  67
Joined:  2009-01-26
Athens, Greece
 

Hi,

I am having the same issue. It seems magento is trying to insert a row to SALES_FLAT_ORDER with the increment_id of the previous order of the customer.

Any luck finding a solution?

Thanks,
Michael

 
Magento Community Magento Community
Magento Community
Magento Community
 
mpikounis
Member
 
Total Posts:  67
Joined:  2009-01-26
Athens, Greece
 

Ok, I did the following: I update the conflicting line in the SALES_FLAT_ORDER table and changed the increment_id to 99999999. I then tried placing the order again and it succeeded. BUT the increment_id of the new order is the same as the increment_id of the last order the customer had placed!! This is a major bug, and unless it is caused by a misbehaving addon I am surprised it hasn’t been caught by the magento development team.

Michael

 
Magento Community Magento Community
Magento Community
Magento Community
 
pschmidt
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2008-09-25
New York
 

Nope. Bug is still there… It’s not just the flat_order table you need to update, but any associated eav_entity_store values too.

So, go to the admin->sales->orders screen and look for the last successful order id.
go into eav_entity_store and in the last_increment_id column look for increments that match the last good order and update them by 2.

Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
munichxmedia
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2009-11-12
 

try This:

http://www.morningtime.nl/kb/173

copy /app/code/core/Mage/Sales/Model/Resource/Quote.php to /app/code/local/Mage/Sales/Model/Resource/Quote.php

change $bind = array(’:increment_id’ => (int)$orderIncrementId); to $bind = array(’:increment_id’ => $orderIncrementId);

this should fix the problem!

 
Magento Community Magento Community
Magento Community
Magento Community
 
twick100
Member
 
Total Posts:  42
Joined:  2009-07-15
 
pschmidt - 21 September 2012 05:35 AM

Nope. Bug is still there… It’s not just the flat_order table you need to update, but any associated eav_entity_store values too.

So, go to the admin->sales->orders screen and look for the last successful order id.
go into eav_entity_store and in the last_increment_id column look for increments that match the last good order and update them by 2.

Hope this helps.

I know I’m late on this but I just had to say.. this has saved me.  I was having this duplication error and pulling out my hair, other solutions suggested removing all logs, quotes, and removing the MYSQL unique check..  All I did was increment eav_entity_store and it fixed my problem right away…

Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
dgir
Member
 
Total Posts:  35
Joined:  2010-12-09
 
munichxmedia - 08 October 2012 04:07 PM

try This:

http://www.morningtime.nl/kb/173

copy /app/code/core/Mage/Sales/Model/Resource/Quote.php to /app/code/local/Mage/Sales/Model/Resource/Quote.php

change $bind = array(’:increment_id’ => (int)$orderIncrementId); to $bind = array(’:increment_id’ => $orderIncrementId);

this should fix the problem!

This fixed the problem for me.

Thanks you very very much

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2