Home >Backend Development >PHP Tutorial >items with the same id already exist in magento
1. I recently encountered such a problem in the magento project (content of the error log):
<code>a:5:{i:0;s:69:"Item (Mage_SalesRule_Model_Rule) with the same id "105" already exist";i:1;s:5399:"#0 /home/websites/blueberrypet/com170/lib/Varien/Data/Collection/Db.php(576): Varien_Data_Collection->addItem(Object(Mage_SalesRule_Model_Rule)) #1 /home/websites/blueberrypet/com170/app/code/core/Mage/SalesRule/Model/Validator.php(100): Varien_Data_Collection_Db->load() #2 /home/websites/blueberrypet/com170/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php(60): Mage_SalesRule_Model_Validator->init('1', '1', 'blueberrypet25') #3 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote/Address.php(957): Mage_SalesRule_Model_Quote_Freeshipping->collect(Object(Mage_Sales_Model_Quote_Address)) #4 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(1263): Mage_Sales_Model_Quote_Address->collectTotals() #5 /home/websites/blueberrypet/com170/app/code/local/Idev/OneStepCheckout/Model/Sales/Quote.php(27): Mage_Sales_Model_Quote->collectTotals() #6 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(1839): Idev_OneStepCheckout_Model_Sales_Quote->collectTotals() #7 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(354): Mage_Sales_Model_Quote->_afterLoad() #8 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Model/Session.php(148): Mage_Sales_Model_Quote->loadByCustomer(Object(Mage_Customer_Model_Customer)) #9 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Model/Cart.php(521): Mage_Checkout_Model_Session->getQuote() #10 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Block/Cart/Sidebar.php(189): Mage_Checkout_Model_Cart->getSummaryQty() #11 /home/websites/blueberrypet/com170/app/design/frontend/blueberrypet_pkg/default/template/checkout/cart/cartheader.phtml(35): Mage_Checkout_Block_Cart_Sidebar->getSummaryCount() #12 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #13 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/bluebe...') #14 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #15 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #16 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() #17 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('topCart', true) #18 /home/websites/blueberrypet/com170/app/design/frontend/blueberrypet_pkg/default/template/page/html/header.phtml(45): Mage_Core_Block_Abstract->getChildHtml('topCart') #19 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #20 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/bluebe...') #21 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #22 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #23 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() #24 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('header', true) #25 /home/websites/blueberrypet/com170/app/design/frontend/base/default/template/page/2columns-left.phtml(42): Mage_Core_Block_Abstract->getChildHtml('header') #26 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #27 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...') #28 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #29 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #30 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml() #31 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput() #32 /home/websites/blueberrypet/com170/app/code/core/Mage/Customer/controllers/AccountController.php(115): Mage_Core_Controller_Varien_Action->renderLayout() #33 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Customer_AccountController->indexAction() #34 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index') #35 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #36 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #37 /home/websites/blueberrypet/com170/app/Mage.php(683): Mage_Core_Model_App->run(Array) #38 /home/websites/blueberrypet/com170/index.php(99): Mage::run('', 'store') #39 {main}";s:3:"url";s:18:"/customer/account/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}</code>
Dear masters, please help me and see how to solve this problem. Thank you!
1. I recently encountered such a problem in the magento project (content of the error log):
<code>a:5:{i:0;s:69:"Item (Mage_SalesRule_Model_Rule) with the same id "105" already exist";i:1;s:5399:"#0 /home/websites/blueberrypet/com170/lib/Varien/Data/Collection/Db.php(576): Varien_Data_Collection->addItem(Object(Mage_SalesRule_Model_Rule)) #1 /home/websites/blueberrypet/com170/app/code/core/Mage/SalesRule/Model/Validator.php(100): Varien_Data_Collection_Db->load() #2 /home/websites/blueberrypet/com170/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php(60): Mage_SalesRule_Model_Validator->init('1', '1', 'blueberrypet25') #3 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote/Address.php(957): Mage_SalesRule_Model_Quote_Freeshipping->collect(Object(Mage_Sales_Model_Quote_Address)) #4 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(1263): Mage_Sales_Model_Quote_Address->collectTotals() #5 /home/websites/blueberrypet/com170/app/code/local/Idev/OneStepCheckout/Model/Sales/Quote.php(27): Mage_Sales_Model_Quote->collectTotals() #6 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(1839): Idev_OneStepCheckout_Model_Sales_Quote->collectTotals() #7 /home/websites/blueberrypet/com170/app/code/core/Mage/Sales/Model/Quote.php(354): Mage_Sales_Model_Quote->_afterLoad() #8 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Model/Session.php(148): Mage_Sales_Model_Quote->loadByCustomer(Object(Mage_Customer_Model_Customer)) #9 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Model/Cart.php(521): Mage_Checkout_Model_Session->getQuote() #10 /home/websites/blueberrypet/com170/app/code/core/Mage/Checkout/Block/Cart/Sidebar.php(189): Mage_Checkout_Model_Cart->getSummaryQty() #11 /home/websites/blueberrypet/com170/app/design/frontend/blueberrypet_pkg/default/template/checkout/cart/cartheader.phtml(35): Mage_Checkout_Block_Cart_Sidebar->getSummaryCount() #12 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #13 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/bluebe...') #14 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #15 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #16 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() #17 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('topCart', true) #18 /home/websites/blueberrypet/com170/app/design/frontend/blueberrypet_pkg/default/template/page/html/header.phtml(45): Mage_Core_Block_Abstract->getChildHtml('topCart') #19 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #20 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/bluebe...') #21 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #22 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #23 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() #24 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('header', true) #25 /home/websites/blueberrypet/com170/app/design/frontend/base/default/template/page/2columns-left.phtml(42): Mage_Core_Block_Abstract->getChildHtml('header') #26 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(241): include('/home/websites/...') #27 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...') #28 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() #29 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() #30 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml() #31 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput() #32 /home/websites/blueberrypet/com170/app/code/core/Mage/Customer/controllers/AccountController.php(115): Mage_Core_Controller_Varien_Action->renderLayout() #33 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Customer_AccountController->indexAction() #34 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index') #35 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #36 /home/websites/blueberrypet/com170/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #37 /home/websites/blueberrypet/com170/app/Mage.php(683): Mage_Core_Model_App->run(Array) #38 /home/websites/blueberrypet/com170/index.php(99): Mage::run('', 'store') #39 {main}";s:3:"url";s:18:"/customer/account/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}</code>
Dear masters, please help me and see how to solve this problem. Thank you!