Magento Enterprise Catalog活动
我正在开发一个扩展,该扩展将在保存时从 Magento(企业)接收 CatalogEvent 信息,并对信息进行自定义处理。
这是我用来监听事件的代码:
<?xml version="1.0"?>
<config>
<global>
<models>
<mage4ucustomredirect>
<class>Mage4u_Customredirect</class>
</mage4ucustomredirect>
</models>
<events>
<enterprise_catalogevent_event>
<observers>
<abc>
<type>singleton</type>
<class>Mage4u_Customredirect_Model_Observer</class>
<method>on_enterprise_catalogevent_event</method>
</abc>
</observers>
</enterprise_catalogevent_event>
</events>
</global>
</config>
这是观察者:
class Mage4u_Customredirect_Model_Observer
{
public function on_enterprise_catalogevent_event(Varien_Event_Observer $observer)
{
Mage::log( "on_enterprise_catalogevent_event" );
}
}
?>
当我保存 CatalogEvent 时,我没有收到调用。你能发现我的代码有什么问题吗?
I'm working on an extension that will receive CatalogEvent information from Magento (Enterprise) when saved and do custom processing on the information.
Here's the code I use to listen to the event:
<?xml version="1.0"?>
<config>
<global>
<models>
<mage4ucustomredirect>
<class>Mage4u_Customredirect</class>
</mage4ucustomredirect>
</models>
<events>
<enterprise_catalogevent_event>
<observers>
<abc>
<type>singleton</type>
<class>Mage4u_Customredirect_Model_Observer</class>
<method>on_enterprise_catalogevent_event</method>
</abc>
</observers>
</enterprise_catalogevent_event>
</events>
</global>
</config>
and this is the observer:
class Mage4u_Customredirect_Model_Observer
{
public function on_enterprise_catalogevent_event(Varien_Event_Observer $observer)
{
Mage::log( "on_enterprise_catalogevent_event" );
}
}
?>
When I save the CatalogEvent, I do not receive the call. Can you spot any problems with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的观察者不会被调用,因为
enterprise_catalog_event
是一个模型,但不是事件。请参阅
app/code/core/Enterprise/CatalogEvent/etc/config.xml
:Afaik
enterprise_catalogevent/event
不会调度自己的保存事件,但您可以观察通用 < code>model_save_before 或model_save_after
事件,用于在创建/保存此类模型时接收回调。您只需要首先识别传递给这些通用事件的对象:
Your observer isn't called, because
enterprise_catalog_event
is a model, but not an event.See
app/code/core/Enterprise/CatalogEvent/etc/config.xml
:Afaik
enterprise_catalogevent/event
does not dispatch its own save events, but you could observe the genericmodel_save_before
ormodel_save_after
event, to receive callbacks whenever such model is being created/saved.You just need to identify the object being passed to these generic events first:
请尝试这个:
Please try this: