1
我想在Magento中设置一个观察者,在订单状态发生变化时执行操作。在Magento中设置观察者的正确方法是什么?
我熟悉创建模块的过程。我期望理解的是需要在模块config.xml中放置什么,以及需要创建的类和/或方法的命名约定是什么。
我想在Magento中设置一个观察者,在订单状态发生变化时执行操作。在Magento中设置观察者的正确方法是什么?
我熟悉创建模块的过程。我期望理解的是需要在模块config.xml中放置什么,以及需要创建的类和/或方法的命名约定是什么。
我没有看到事件名称的任何地方,但我会在这里发表的一般情形:
假定:你有一个模块设置,高配车型正在从Yourmodule /型号目录正确加载。 。
在你的模块的config.xml文件:
<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%/型号/ Observer.php具有以下内容:
<?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
真的,你可以在你的观察者中命名你想要的方法,但是这个模式似乎是将类本身命名为Observer。它使用正常模型加载(例如yourmodule/observer映射到Yourmodule_Model_Observer)加载。希望有所帮助!
谢谢, 乔
事实是,我解决了我的问题一种不同的方式。这看起来对我来说虽然。 – Laizer 2010-01-25 17:28:29