cancel
Showing results for 
Search instead for 
Did you mean: 

Add to cart not working for some products

Add to cart not working for some products

 Hi,

 

The Magento store of my customer is running under version 1.9.1.1.

It appears than some products can't be added to cart, with the simple returning message "Unable to add product to cart". Older products may be added, as opposed to more recently added products.

 

I have this error in exception.log :

 

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`htf_magento`.`sales_flat_quote_item`, CONSTRAINT `FK_SALES_FLAT_QUOTE_ITEM_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity_OLD` (`entity_id`) ON DEL), query was: INSERT INTO `sales_flat_quote_item` (`quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `is_virtual`, `sku`, `name`, `applied_rule_ids`, `free_shipping`, `is_qty_decimal`, `weight`, `qty`, `price`, `base_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_weight`, `product_type`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `base_weee_tax_applied_amount`) VALUES (?, '2018-07-23 13:09:08', '2018-07-23 13:09:08', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' in /home/htf/www/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /home/htf/www/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/htf/www/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/htf/www/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/htf/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `sa...', Array)
#4 /home/htf/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `sa...', Array)
#5 /home/htf/www/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `sa...', Array)
#6 /home/htf/www/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('sales_flat_quot...', Array)
#7 /home/htf/www/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Quote_Item))
#8 /home/htf/www/app/code/core/Mage/Sales/Model/Quote/Item.php(749): Mage_Core_Model_Abstract->save()
#9 /home/htf/www/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(652): Mage_Sales_Model_Quote_Item->save()
#10 /home/htf/www/app/code/core/Mage/Sales/Model/Quote.php(340): Mage_Core_Model_Resource_Db_Collection_Abstract->save()
#11 /home/htf/www/app/code/core/Mage/Core/Model/Abstract.php(319): Mage_Sales_Model_Quote->_afterSave()
#12 /home/htf/www/app/code/core/Mage/Sales/Model/Quote.php(1966): Mage_Core_Model_Abstract->save()
#13 /home/htf/www/app/code/core/Mage/Checkout/Model/Cart.php(459): Mage_Sales_Model_Quote->save()
#14 /home/htf/www/app/code/core/Mage/Checkout/controllers/CartController.php(223): Mage_Checkout_Model_Cart->save()
#15 /home/htf/www/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Checkout_CartController->addAction()
#16 /home/htf/www/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('add')
#17 /home/htf/www/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#18 /home/htf/www/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#19 /home/htf/www/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#20 /home/htf/www/index.php(105): Mage::run('', 'store')
#21 {main}

Would anyone have any idea of the origin of the problem?