The issue: In Magento admin panel, when generating report via Reports - Products - Products Ordered, an error occurs:
Item (Mage_Catalog_Model_Product) with the same id "45" already exist #0 /home/glassesm/public_html/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(236): Varien_Data_Collection->addItem(Object(Mage_Catalog_Model_Product)) #1 /home/glassesm/public_html/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(964): Mage_Eav_Model_Entity_Collection_Abstract->addItem(Object(Mage_Catalog_Model_Product)) #2 /home/glassesm/public_html/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(794): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false) #3 /home/glassesm/public_html/lib/Varien/Data/Collection.php(729): Mage_Eav_Model_Entity_Collection_Abstract->load() #4 /home/glassesm/public_html/app/code/core/Mage/Reports/Model/Totals.php(53): Varien_Data_Collection->getIterator() #5 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Report/Grid.php(368): Mage_Reports_Model_Totals->countTotals(Object(Mage_Adminhtml_Block_Report_Product_Sold_Grid), '2011-12-10 00:0...', '2011-12-10 23:5...') #6 /home/glassesm/public_html/app/design/adminhtml/default/default/template/report/grid.phtml(138): Mage_Adminhtml_Block_Report_Grid->getReport('2011-12-10 00:0...', '2011-12-10 23:5...') #7 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(216): include('/home/glassesm/...') #8 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(247): Mage_Core_Block_Template->fetchView('adminhtml/defau...') #9 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(261): Mage_Core_Block_Template->renderView() #10 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml() #11 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(758): Mage_Adminhtml_Block_Template->_toHtml() #12 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(525): Mage_Core_Block_Abstract->toHtml() #13 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(476): Mage_Core_Block_Abstract->_getChildHtml('grid', true) #14 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php(70): Mage_Core_Block_Abstract->getChildHtml('grid') #15 /home/glassesm/public_html/app/design/adminhtml/default/default/template/widget/grid/container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml() #16 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(216): include('/home/glassesm/...') #17 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(247): Mage_Core_Block_Template->fetchView('adminhtml/defau...') #18 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(261): Mage_Core_Block_Template->renderView() #19 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml() #20 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Widget/Container.php(295): Mage_Adminhtml_Block_Template->_toHtml() #21 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(758): Mage_Adminhtml_Block_Widget_Container->_toHtml() #22 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml() #23 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(758): Mage_Core_Block_Text_List->_toHtml() #24 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(525): Mage_Core_Block_Abstract->toHtml() #25 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(476): Mage_Core_Block_Abstract->_getChildHtml('content', true) #26 /home/glassesm/public_html/app/design/adminhtml/default/default/template/page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content') #27 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(216): include('/home/glassesm/...') #28 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(247): Mage_Core_Block_Template->fetchView('adminhtml/defau...') #29 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Template.php(261): Mage_Core_Block_Template->renderView() #30 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml() #31 /home/glassesm/public_html/app/code/core/Mage/Core/Block/Abstract.php(758): Mage_Adminhtml_Block_Template->_toHtml() #32 /home/glassesm/public_html/app/code/core/Mage/Core/Model/Layout.php(529): Mage_Core_Block_Abstract->toHtml() #33 /home/glassesm/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(389): Mage_Core_Model_Layout->getOutput() #34 /home/glassesm/public_html/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php(97): Mage_Core_Controller_Varien_Action->renderLayout() #35 /home/glassesm/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Report_ProductController->soldAction() #36 /home/glassesm/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('sold') #37 /home/glassesm/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)) #38 /home/glassesm/public_html/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch() #39 /home/glassesm/public_html/app/Mage.php(627): Mage_Core_Model_App->run(Array) #40 /home/glassesm/public_html/index.php(80): Mage::run('', 'store') #41 {main}
Could you help me with this issue ?
$collection->distinct(true);
– Damodar Bashyal