Magento Admin Login Error – Fixing Duplicate Sales Order ID

magento-1.9sales-order

I get this error when trying to log in to my admin. Please help!

/lib/Varien/Data/Collection/Db.php(576): Varien_Data_Collection->addItem(Object(Mage_Sales_Model_Order))

Trace: 
0 /lib/Varien/Data/Collection/Db.php(576):Varien_Data_Collection->addItem(Object(Mage_Sales_Model_Order)) 
1 /app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(533):Varien_Data_Collection_Db->load() 
2 /app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php(61): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()

Best Answer

This error is stating that your Varien_Data_Collection filter return two order with the same ID 1178.

This may be the result of two things,

  1. You/module is doing a custom query that return multiple record with the same id. You may need to use a group by since Varien_Data_Collection can not have duplicate id

  2. Duplicate recode in sales_flat_order (next to impossible because entity_id should be a primary key

How many rows the code below return

select * from sales_flat_order where entity_id = 1178
Related Topic