我最近将我的Magento商店从1.4.2升级到1.7.0.2。 现在,当我尝试将产品添加到购物车时,它会显示以下错误:
无法将商品添加到购物车。
这是堆栈跟踪:
2012-11-23T12:26:33+00:00 DEBUG (7): Exception message: Invalid method Mage_Catalog_Model_Product::prepareCustomOptions(Array
(
)
)
Trace: #0 [internal function]: Varien_Object->__call('prepareCustomOp...', Array)
#1 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php(357): Mage_Catalog_Model_Product->prepareCustomOptions()
#2 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php(294): Mage_Catalog_Model_Product_Type_Abstract->_prepareProduct(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#3 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php(410): Mage_Catalog_Model_Product_Type_Grouped->_prepareProduct(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#4 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Sales/Model/Quote.php(901): Mage_Catalog_Model_Product_Type_Abstract->prepareForCartAdvanced(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#5 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Sales/Model/Quote.php(978): Mage_Sales_Model_Quote->addProductAdvanced(Object(Mage_Catalog_Model_Product), Object(Varien_Object), 'full')
#6 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Checkout/Model/Cart.php(271): Mage_Sales_Model_Quote->addProduct(Object(Mage_Catalog_Model_Product), Object(Varien_Object))
#7 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Checkout/controllers/CartController.php(193): Mage_Checkout_Model_Cart->addProduct(Object(Mage_Catalog_Model_Product), Array)
#8 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_CartController->addAction()
#9 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('add')
#10 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/local/MW/Developertoolbar/Controller/Router/Standard.php(42): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): MW_Developertoolbar_Controller_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /var/www/vhosts/medicalemcasa.com/httpdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#14 /var/www/vhosts/medicalemcasa.com/httpdocs/index.php(87): Mage::run('', 'store')
#15 {main}
2012-11-23T12:26:33+00:00 ERR (3):
exception 'Varien_Exception' with message 'Invalid method Mage_Catalog_Model_Product::prepareCustomOptions(Array
(
)
)' in /var/www/vhosts/medicalemcasa.com/httpdocs/lib/Varien/Object.php:652
Stack trace:
#0 [internal function]: Varien_Object->__call('prepareCustomOp...', Array)
#1 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php(357): Mage_Catalog_Model_Product->prepareCustomOptions()
#2 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php(294): Mage_Catalog_Model_Product_Type_Abstract->_prepareProduct(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#3 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php(410): Mage_Catalog_Model_Product_Type_Grouped->_prepareProduct(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#4 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Sales/Model/Quote.php(901): Mage_Catalog_Model_Product_Type_Abstract->prepareForCartAdvanced(Object(Varien_Object), Object(Mage_Catalog_Model_Product), 'full')
#5 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Sales/Model/Quote.php(978): Mage_Sales_Model_Quote->addProductAdvanced(Object(Mage_Catalog_Model_Product), Object(Varien_Object), 'full')
#6 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Checkout/Model/Cart.php(271): Mage_Sales_Model_Quote->addProduct(Object(Mage_Catalog_Model_Product), Object(Varien_Object))
#7 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Checkout/controllers/CartController.php(193): Mage_Checkout_Model_Cart->addProduct(Object(Mage_Catalog_Model_Product), Array)
#8 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_CartController->addAction()
#9 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('add')
#10 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/local/MW/Developertoolbar/Controller/Router/Standard.php(42): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): MW_Developertoolbar_Controller_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /var/www/vhosts/medicalemcasa.com/httpdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /var/www/vhosts/medicalemcasa.com/httpdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#14 /var/www/vhosts/medicalemcasa.com/httpdocs/index.php(87): Mage::run('', 'store')
#15 {main}
如果有帮助的话,我正在尝试将简单的产品添加到购物车中。
知道发生了什么事吗?
答案 0 :(得分:0)
检查您的代码中是否有任何观察者,或者您添加的新扩展程序在您向卡中添加项目时会触发,请找到我为解决问题而修复的以下代码
原件:
$item = $observer->getEvent()->getQuoteItem();
$product = $item->getProduct();
$item->setMerchant($product->getMethant());
$item->save();
解决方案:
$quoteItem = $observer->getQuoteItem();
$product = $observer->getProduct();
$quoteItem->setCustomAttribute($product->getCustomAttribute());
答案 1 :(得分:-2)
好的,我试图理解是什么引起了这个错误,但无济于事。
所以我通过安装Magento 1.7的全新安装解决了这个问题,并从那里升级了我的magento商店。