0

Started getting this error when I'm trying to add a product to the basket:

cannot add the item to shopping cart

the exception.log had the following error:

2013-04-02T14:45:35+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`bespoken_mgn1`.`mgn_sales_flat_quote_item`, CONSTRAINT `FK_687093A92A4F71BEF47F9AC76B2E2F25` FOREIGN KEY (`quote_id`) REFERENCES `mgn_sales_flat_quote` (`entity_id`) ON DELETE CASCADE ON UPDA)
Trace: #0 /home6/bespoken/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home6/bespoken/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home6/bespoken/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home6/bespoken/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `mg...', Array)
#4 /home6/bespoken/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `mg...', Array)
#5 /home6/bespoken/public_html/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `mg...', Array)
#6 /home6/bespoken/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('mgn_sales_flat_...', Array)
#7 /home6/bespoken/public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Quote_Item))
#8 /home6/bespoken/public_html/app/code/core/Mage/Sales/Model/Quote/Item.php(751): Mage_Core_Model_Abstract->save()
#9 /home6/bespoken/public_html/app/code/local/EmmanuelOrduna/UpdateProductPrice/Model/Observer.php(20): Mage_Sales_Model_Quote_Item->save()
#10 /home6/bespoken/public_html/app/code/core/Mage/Core/Model/App.php(1338): EmmanuelOrduna_UpdateProductPrice_Model_Observer->updatePrice(Object(Varien_Event_Observer))
#11 /home6/bespoken/public_html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(EmmanuelOrduna_UpdateProductPrice_Model_Observer), 'updatePrice', Object(Varien_Event_Observer))
#12 /home6/bespoken/public_html/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('sales_quote_add...', Array)
#13 /home6/bespoken/public_html/app/code/core/Mage/Sales/Model/Quote.php(874): Mage::dispatchEvent('sales_quote_add...', Array)
#14 /home6/bespoken/public_html/app/code/core/Mage/Sales/Model/Quote.php(1015): Mage_Sales_Model_Quote->addItem(Object(Mage_Sales_Model_Quote_Item))
#15 /home6/bespoken/public_html/app/code/core/Mage/Sales/Model/Quote.php(924): Mage_Sales_Model_Quote->_addCatalogProduct(Object(Mage_Catalog_Model_Product), '1')
#16 /home6/bespoken/public_html/app/code/core/Mage/Sales/Model/Quote.php(978): Mage_Sales_Model_Quote->addProductAdvanced(Object(Mage_Catalog_Model_Product), Object(Varien_Object), 'full')
#17 /home6/bespoken/public_html/app/code/core/Mage/Checkout/Model/Cart.php(271): Mage_Sales_Model_Quote->addProduct(Object(Mage_Catalog_Model_Product), Object(Varien_Object))
#18 /home6/bespoken/public_html/app/code/core/Mage/Checkout/controllers/CartController.php(193): Mage_Checkout_Model_Cart->addProduct(Object(Mage_Catalog_Model_Product), Array)
#19 /home6/bespoken/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_CartController->addAction()
#20 /home6/bespoken/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('add')
#21 /home6/bespoken/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))
#22 /home6/bespoken/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#23 /home6/bespoken/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#24 /home6/bespoken/public_html/index.php(87): Mage::run('', 'store')
#25 {main}

Edit

I had an Observer module with issues causing a problem. Disabled it and all worked fine!

closed as too localized by Ben Lessani - Sonassi, Marius, Fabian Blechschmidt, davidalger, philwinkle Apr 23 '13 at 18:44

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

8
#9 /home6/bespoken/public_html/app/code/local/EmmanuelOrduna/UpdateProductPrice/Model/Observer.php(20): Mage_Sales_Model_Quote_Item->save()

In this line, I can see that you have a Observer class that is trying to save a Mage_Sales_Model_Quote_Item when an item is being added to the cart.

You do not need to call save() on the quote, whatever changes you do on the quote variable, it will be saved automatically later on as the variable is being passed by reference.

Not the answer you're looking for? Browse other questions tagged or ask your own question.