我有以下觀察員方法:
public function ModifyOrderECC(Varien_Event_Observer $observer)
{
//sales_order_place_before
Mage::log('ECC!! = ModifyOrderECC has been called successfully - event/array-5', null, 'mylog.log');
$cart = $observer->getEvent()->getCart();
try{
if($cart != NULL)
{
Mage::log('$cart contains data!', null, 'mylog.log');
foreach ($cart->getItems() as $item) {
$getID = $item->getProduct()->getId();
$productName = $item->getProduct()->getName();
$productPrice = $item->getProduct()->getPrice();
$quantity = (string)$item->getProduct()->getQtyOrdered();
Mage::log('ID: '.$getID, null, 'mylog.log');
Mage::log('Name: '.$productName, null, 'mylog.log');
Mage::log('Price: '.$productPrice, null, 'mylog.log');
Mage::log('Qty: '.$quantity, null, 'mylog.log');
}
}else
{
Mage::log('sorry Cart is null :(', null, 'mylog.log');
}
}catch(Exception $e)
{
Mage::log($e->getMessage());
Mage::log('error = '.$e->getMessage(), null, 'mylog.log');
}
}
但是getCart事件是空的,我也試了getQuote這也爲空。我需要從活動中獲取購物車的內容,以查看其創建的內容。有任何想法嗎?
在$ observer中你只有訂單,getQuoteId將返回null –
有一些錯誤。現在回答是更新..請立即檢查 –