我有一个magento商店,所有这些认为运作良好,第一次添加到购物车运作良好,成功结帐和付款完成。我想在我的购物车中添加另一个产品时,我无法在购物车中添加任何产品,退出后再次登录其运行良好,但付款完成后我无法在购物车中添加产品。我搜索了很多但是无法获得成功。请帮我简短一下这个问题。我使用的是magento 1.8.0.0
错误讯息:
a:5:{i:0;s:313:"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`intercon_2Einter`.`sales_flat_quote_item`, CONSTRAINT `FK_SALES_FLAT_QUOTE_ITEM_QUOTE_ID_SALES_FLAT_QUOTE_ENTITY_ID` FOREIGN KEY (`quote_id`) REFERENCES `sales_flat_quote` (`entity_id`) ON DE)";i:1;s:4159:"#0 /home/intercon/domains/dekabelexpert.nl/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/intercon/domains/dekabelexpert.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/intercon/domains/dekabelexpert.nl/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `sa...', Array)
#4 /home/intercon/domains/dekabelexpert.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `sa...', Array)
#5 /home/intercon/domains/dekabelexpert.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `sa...', Array)
#6 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('sales_flat_quot...', Array)
#7 /home/intercon/domains/dekabelexpert.nl/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 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Sales/Model/Quote/Item.php(735): Mage_Core_Model_Abstract->save()
#9 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/local/Ajax/ProductAdjust/Model/Observer.php(92): Mage_Sales_Model_Quote_Item->save()
#10 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Model/App.php(1338): Ajax_ProductAdjust_Model_Observer->updatePrice(Object(Varien_Event_Observer))
#11 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Ajax_ProductAdjust_Model_Observer), 'updatePrice', Object(Varien_Event_Observer))
#12 /home/intercon/domains/dekabelexpert.nl/public_html/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('sales_quote_add...', Array)
#13 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Sales/Model/Quote.php(942): Mage::dispatchEvent('sales_quote_add...', Array)
#14 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Sales/Model/Quote.php(1083): Mage_Sales_Model_Quote->addItem(Object(Mage_Sales_Model_Quote_Item))
#15 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Sales/Model/Quote.php(992): Mage_Sales_Model_Quote->_addCatalogProduct(Object(Mage_Catalog_Model_Product), '1')
#16 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Sales/Model/Quote.php(1046): Mage_Sales_Model_Quote->addProductAdvanced(Object(Mage_Catalog_Model_Product), Object(Varien_Object), 'full')
#17 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Checkout/Model/Cart.php(265): Mage_Sales_Model_Quote->addProduct(Object(Mage_Catalog_Model_Product), Object(Varien_Object))
#18 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/local/Softprodigy/Multipleaddtocart/controllers/AddController.php(89): Mage_Checkout_Model_Cart->addProduct(Object(Mage_Catalog_Model_Product), Array)
#19 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Softprodigy_Multipleaddtocart_AddController->checksingleAction()
#20 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('checksingle')
#21 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#22 /home/intercon/domains/dekabelexpert.nl/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#23 /home/intercon/domains/dekabelexpert.nl/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#24 /home/intercon/domains/dekabelexpert.nl/public_html/index.php(87): Mage::run('', 'store')
#25
答案 0 :(得分:0)
我遇到了同样的问题:
我把它缩小到sales_quote_item_set_product
上的观察者。在这个观察者中,我修改了QuoteItem(设置价格和添加选项),然后我保存了它。我认为储蓄导致了这个问题。
我将逻辑移到sales_quote_save_after
事件,两个错误都消失了。希望它有所帮助。
答案 1 :(得分:0)
使用sales_quote_add_item
事件观察器时遇到此问题。我试图以编程方式编辑产品价格,同时将产品添加到购物车中。
我在 Observer 类中保存了引用项。
$quoteItem->save();
后来,我发现我们不需要保存引用项目对象,因为它会在以后通过引用传递时自动保存。
因此,解决方案是删除/评论该行:
// $quoteItem->save();