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

Order saving error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-28’ for key 2
 
ffab
Jr. Member
 
Total Posts:  17
Joined:  2008-09-25
 

Hello

i’m running magento 1.6.1, when i try to place a order in the backend/frontend i have this kind of error showing up.

Order saving error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-28’ for key 2

trace

2011-12-20T05:40:18+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-28’ for key 2
Trace: #0 /var/www/html/f/shop/magento/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/html/f/shop/magento/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/html/f/shop/magento/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /var/www/html/f/shop/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(’INSERT INTO `sa...’, Array)
#4 /var/www/html/f/shop/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query(’INSERT INTO `sa...’, Array)
#5 /var/www/html/f/shop/magento/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query(’INSERT INTO `sa...’, Array)
#6 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(448): Zend_Db_Adapter_Abstract->insert(’sales_order_tax...’, Array)
#7 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Tax_Model_Sales_Order_Tax_Item))
#8 /var/www/html/f/shop/magento/app/code/core/Mage/Tax/Model/Observer.php(144): Mage_Core_Model_Abstract->save()
#9 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/App.php(1303): Mage_Tax_Model_Observer->salesEventOrderAfterSave(Object(Varien_Event_Observer))
#10 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/App.php(1284): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Tax_Model_Observer), ‘salesEventOrder...’, Object(Varien_Event_Observer))
#11 /var/www/html/f/shop/magento/app/Mage.php(416): Mage_Core_Model_App->dispatchEvent(’sales_order_sav...’, Array)
#12 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/Abstract.php(466): Mage::dispatchEvent(’sales_order_sav...’, Array)
#13 /var/www/html/f/shop/magento/app/code/core/Mage/Sales/Model/Abstract.php(53): Mage_Core_Model_Abstract->_afterSave()
#14 /var/www/html/f/shop/magento/app/code/core/Mage/Sales/Model/Order.php(2134): Mage_Sales_Model_Abstract->_afterSave()
#15 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/Abstract.php(319): Mage_Sales_Model_Order->_afterSave()
#16 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#17 /var/www/html/f/shop/magento/app/code/core/Mage/Sales/Model/Service/Quote.php(189): Mage_Core_Model_Resource_Transaction->save()
#18 /var/www/html/f/shop/magento/app/code/core/Mage/Sales/Model/Service/Quote.php(126): Mage_Sales_Model_Service_Quote->submitOrder()
#19 /var/www/html/f/shop/magento/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php(1464): Mage_Sales_Model_Service_Quote->submit()
#20 /var/www/html/f/shop/magento/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php(475): Mage_Adminhtml_Model_Sales_Order_Create->createOrder()
#21 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Adminhtml_Sales_Order_CreateController->saveAction()
#22 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch(’save’)
#23 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#24 /var/www/html/f/shop/magento/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#25 /var/www/html/f/shop/magento/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#26 /var/www/html/f/shop/magento/index.php(80): Mage::run(’’, ‘store’)
#27 {main}

Browsing forum and searching the internet i tried to
- clean log
- clean var/cache

Precision
- no product was imported using dataflow, they are all typed in using backend
- orginal install was 1.6.0, upgrade in dev mode (without testing the cart before i was in 1.6.1)

Can anyone help me on this ?

Cheers,

 
Magento Community Magento Community
Magento Community
Magento Community
 
thehosh
Jr. Member
 
Total Posts:  14
Joined:  2011-07-11
 

A bump to this, except I have imported some stuff from another installation (which I wanted to turn into one store). I tried the suggestions in another thread, but none worked.

 
Magento Community Magento Community
Magento Community
Magento Community
 
attermire
Jr. Member
 
Total Posts:  4
Joined:  2009-09-23
 

I was getting this same problem/error

I noticed that the order was created ok if i added a product with no tax assigned to it.
I then discovered that my tax was not set up right.

I had a tax rule setup for shipping using the SAME product tax class as the rule that i was applying to the products.
When i removed this product tax class from the shipping tax rule and added the shipping product tax class to this rule the problem went away.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kalenjordan
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2011-10-31
Pasadena, CA
 

That particular integrity constraint violation means that you are attempting to create a record in the sales_order_tax_item table with the same combination of tax_id = 14 / item_id = 28. 

As @thehosh said, it’s got to be related to having some kind of duplicate or mis-configured tax rule setup.  Start by looking into your tax rule with ID 14.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top