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

在 Magento 中設置觀察者的正確方法是什么?

What is the correct way to set up an observer in Magento?(在 Magento 中設置觀察者的正確方法是什么?)
本文介紹了在 Magento 中設置觀察者的正確方法是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在 Magento 中設置一個觀察者,在訂單狀態發生變化時執行一個操作.

I'd like to set up an observer in Magento that performs an action when the status of an order changes.

我熟悉創建模塊的過程.我想了解的是需要在模塊 config.xml 中放置什么,以及需要創建的類和/或方法的命名約定是什么.

I'm familiar with process of creating modules. What I'm looking to understand is what needs to placed in the modules config.xml, and what is the naming convention for the classes and/or methods that need to be created.

推薦答案

我在任何地方都沒有看到事件名稱,但我會在此處發布一般情況:

I don't see the event name anywhere, but I'll post the general case here:

假設:您已經設置了一個模塊,并且從 Yourmodule/Model 目錄中正確加載了模型..

Assumed: That you have a module set up, with models being loaded correctly from the Yourmodule/Model directory..

在您模塊的 config.xml 文件中:

In your module's config.xml file:

<config>
    <global>
  <events>
   <full_event_name>
    <observers>
     <yourmodule>
      <type>singleton</type>
      <class>yourmodule/observer</class>
      <method>yourMethodName</method>
     </yourmodule>
    </observers>
   </full_event_name>
  </events>
 </global>
</config>

創建一個 %yourmodule%/Model/Observer.php 文件,內容如下:

Create a file %yourmodule%/Model/Observer.php with the following contents:

<?php

class Yourmodule_Model_Observer {

    public function yourMethodName($event) {
        $data = $event->getData(); // this follows normal Magento data access

        // perform your action here
    }

}//class Yourmodule_Model_Observer

實際上,您可以在觀察者中隨意命名方法,但模式似乎是將類本身命名為觀察者.它使用普通模型加載(例如 yourmodule/observer 映射到 Yourmodule_Model_Observer)加載.希望有幫助!

Really, you can name the method whatever you want within your observer, but the pattern seems to be to name the class itself Observer. It is loaded using normal model loading (e.g. yourmodule/observer maps to Yourmodule_Model_Observer). Hope that helps!

謝謝,喬

這篇關于在 Magento 中設置觀察者的正確方法是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 西西裸体做爰视频 | 视频三区 | www.99精品 | 在线观看av不卡 | 亚洲视频中文字幕 | 羞羞色视频 | 久久国产一区二区三区 | 精品国产女人 | 国产精品九九九 | 亚洲激情一区二区三区 | 中文字幕在线观看第一页 | 欧美综合一区二区 | 日韩91在线| 欧美日韩一二三区 | 午夜激情一区 | 久久九 | 色婷婷综合久久久中文字幕 | 久久精品国产一区二区电影 | 色天堂影院 | 一区二区中文 | 国产精品高清一区二区 | 欧美午夜精品 | 污视频在线免费观看 | 久久精品小视频 | 亚洲欧美在线一区 | h视频在线免费 | 国产精品欧美一区二区 | 国产成人精品一区二三区在线观看 | 精品日韩在线 | 国产成人精品一区二 | 紧缚调教一区二区三区视频 | 亚洲欧美激情国产综合久久久 | 久久精品一区 | 91在线看网站 | 一区在线观看 | 日韩影音 | 亚洲国产精品久久久久秋霞不卡 | 在线色网 | 久久成人国产 | 夜夜久久 | 黄色免费网址大全 |