久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento 訂單狀態更改事件

Magento order status change events(Magento 訂單狀態更改事件)
本文介紹了Magento 訂單狀態更改事件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想通過 Web 服務更改遠程清單,我知道通過 Event Observer Method 可以觸發我的代碼,但我不知道哪個事件對完成我的任務有用,例如 on_order_complete,是否有更新的列表事件或更多文檔?

I want to change via web service a remote inventory, I know that via Event Observer Method can triger my code, but I don't know which event is useful to complete my task, like on_order_complete, is there an updated list of events or more documentation?

推薦答案

如果您想在訂單狀態更改為任何狀態或狀態時分派事件,則需要插入自己的事件偵聽器.這并不像聽起來那么難.

If you want to dispatch an event when the state of an order changes to any status or state, then you'll need to insert your own event listener. This isn't as difficult as it sounds.

只需像這樣覆蓋Mage_Sales_Model_Order中的_setStatus函數...

Simply override the _setStatus function in Mage_Sales_Model_Order like so...

/**
 * Order model
 *
 * @category    WMG
 * @package     WMG_Sales
 * @author      Lee Bolding <lee.bolding@wmg.com>
 *
 *  Supported events:
 *  sales_order_status_before
 *  sales_order_status_after
 *
 * NOTE: Unfortunately, we can't override setState() as the protected _setState()
 * function is used by the registerCancellation() and _checkState() functions
 *  
 */
class WMG_Sales_Model_Order extends Mage_Sales_Model_Order
{
    /**
     * Order state protected setter.
     * By default allows to set any state. Can also update status to default or specified value
     * Сomplete and closed states are encapsulated intentionally, see the _checkState()
     *
     * @param string $state
     * @param string|bool $status
     * @param string $comment
     * @param bool $isCustomerNotified
     * @param $shouldProtectState
     * @return Mage_Sales_Model_Order
     */
    protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
    {
        // dispatch an event before we attempt to do anything
        Mage::dispatchEvent('sales_order_status_before', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified, 'shouldProtectState' => $shouldProtectState));

        // attempt to set the specified state
        if ($shouldProtectState) {
            if ($this->isStateProtected($state)) {
                Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
            }
        }
        $this->setData('state', $state);

        // add status history
        if ($status) {
            if ($status === true) {
                $status = $this->getConfig()->getStateDefaultStatus($state);
            }
            $this->setStatus($status);
            $history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
            $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
        }

        // dispatch an event after status has changed
        Mage::dispatchEvent('sales_order_status_after', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified, 'shouldProtectState' => $shouldProtectState));

        return $this;
    }
}

您現在可以為觀察者訂閱新創建的 sales_order_status_beforesales_order_status_after 事件

You can now subscribe observers to the newly created sales_order_status_before and sales_order_status_after events

這篇關于Magento 訂單狀態更改事件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Override Magento Config(覆蓋 Magento 配置)
What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導致 print_r 和/或 var_dump 調試變量失敗?)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
Magento 404 on Admin Page(管理頁面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價格規則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產品頁面標題以包含屬性)
主站蜘蛛池模板: 欧日韩不卡在线视频 | 久久久www成人免费无遮挡大片 | www.4虎影院 国产999精品久久久影片官网 | 日本不卡一区二区三区 | 亚洲精品日韩在线 | 99色在线| 欧美精品片 | 天天狠狠| 成人毛片视频免费 | 毛片在线免费 | 国产精品福利在线观看 | 色播99 | 久久69精品久久久久久久电影好 | 中文字幕一区在线 | 狠狠干狠狠插 | 大吊一区二区 | 国产特级毛片aaaaaa喷潮 | 国产毛片久久久 | 伊人二区 | 国产精品永久在线观看 | 亚洲毛片在线观看 | 亚洲黄色一级毛片 | 久久人爽爽人爽爽 | 三级特黄特色视频 | 中文字幕在线观看视频网站 | 91精品国产91久久久久久吃药 | 羞羞的视频在线观看 | 亚洲成人观看 | 青娱乐av | 浴室洗澡偷拍一区二区 | 91久久久www播放日本观看 | www.狠狠干 | 欧美精品久久久久 | 精品国产亚洲一区二区三区大结局 | 欧美精品成人一区二区三区四区 | 欧美国产视频 | 久久久久久久av | 免费视频久久久久 | 国产资源在线视频 | 日本一区视频在线观看 | www.99re|