如何在Observer.php-Magento中调用getItem()&getOptionList()
我有一个观察员结帐\购物车\产品\添加\之后,我想得到选定的自定义选项数组 我在以下方面找到了我需要的两个要素: app/design/frontend/MY-THEME/default/template/checkout/cart/item/default.phtml 它们是: 1. $_item = $this->getItem(); 2. $_options = $this->getOptionList(); 我只是不知道如何让他们在一个观察员,也就是说,什么是我必须呼吁如何在Observer.php-Magento中调用getItem()&getOptionList(),php,magento,observers,Php,Magento,Observers,我有一个观察员结帐\购物车\产品\添加\之后,我想得到选定的自定义选项数组 我在以下方面找到了我需要的两个要素: app/design/frontend/MY-THEME/default/template/checkout/cart/item/default.phtml 它们是: 1. $_item = $this->getItem(); 2. $_options = $this->getOptionList(); 我只是不知道如何让他们在一个观察员,也就是说,什么是我必须呼吁 提前谢谢 请转到
提前谢谢 请转到以下url
http://inchoo.net/magento/updating-options-of-configurable-product-that-is-already-in-the-cart/观察者总是从各自的事件开始返回数据 因此,在您的情况下,您必须首先使用以下行在观察者的函数代码中获取checkout quote对象:
$quote = $observer->getEvent()->getQuote();
然后,您可以从报价中获取items集合中每个项目的自定义选项,如下所示:
$quoteItems = $quote->getAllItems();
$helper = Mage::helper('catalog/product_configuration');
foreach ($quoteItems as $item) {
$product = $item->getProduct();
$options = $helper->getCustomOptions($item);
//do anything with $options.
}
试试这个。希望能有帮助
你是否已经参考了下面的链接