如何在Magento中找到适合的活动? [英] How to find an appropriate event in Magento?

查看:159
本文介绍了如何在Magento中找到适合的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当寻找一个方便的事件钩子我做一些探索性的编程...

Sometimes when looking for a convenient event to hook I do a bit of exploratory programming...


  • 修改 Mage :: dispatchEvent 加上这条额外的行:

Mage::log($name.'('.implode(',', array_keys($data)).')');


  • 标记一个起点,我知道我不能早点抓住:

  • Mark a start point which I know I cannot catch any sooner:

    Mage::log(__METHOD__.'::START');
    


  • 标记一个终点,我以后不想再抓住:

  • Mark an end point which I don't want to catch any later:

    Mage::log(__METHOD__.'::STOP');
    


  • 观看日志并逐步浏览网站(例如订单提交,正在调查的内容)

  • Watch the log and step through the site (eg. order submission, whatever is being investigated)

    tailf var/log/system.log
    


  • 这给了我一个充满无聊的数据和正在传递的对象的名称的屏幕。除了 START STOP 我通常不会找到足够的东西来填补它,我必须依靠我的经验来识别可能的引导点。例如,下订单时,我知道在某个地方经常有报价,或者可以通过付款对象获得订单的引用,反之亦然。

    This gives me a screen full of boring data and the names of objects being passed. Other than the START and STOP I'm usually not looking for anything specific enough to grep for it and I have to rely on my experience to identify possible bootstrap points. For example when placing orders I know there is often a 'quote' somewhere, or it is possible to get a reference to the order through a 'payment' object, or vice-versa.

    然后我必须记得删除我的标记(在使用任何版本的时候不要那么难)。

    Then I have to remember to remove my markers (not that hard when using any sort of versioning).

    你用什么方法来查找事件?您可以在不修改核心代码的情况下执行此操作吗?

    What methods do you use to find events? Can you do it without modifying core code?

    推荐答案

    从1.2开始,事件列表就在Magento Wiki中进行了设计。你可以在这里找到这个清单:

    As of 1.2 the event list was curated on the Magento Wiki. You can find that list here:

    http://www.magentocommerce.com/wiki/_media/magento_events_v1.2.0.2.xls

    然而,从那时起各种事件已被弃用。这里有一个列表,但它只是当前的1.4

    However, since then various events have been deprecated. There is a list here but it's only current as of 1.4

    http://masteringmagento.com/2010/06/events-list-in-magento-community-1-4/

    如果您方便,可以在Magento工作目录中执行 grep -R dispatchEvent ,并通过发送调用。这些是您特定版本中所有Magento活动的实际定义。

    If you're handy, you can execute grep -R dispatchEvent in your Magento working directory and parse through the dearth of dispatch calls. These are the actual definitons of all Magento events in your particular version.

    编辑2/14/2013:

    这个列表,几岁,不再有效。我建议您使用以下资源,因为它不仅是一个更好的答案,而且还提供了许多找到更好的事件钩子的例子和来源。

    This list, being a couple of years old, is no longer valid. I suggest that you use the following resource as it is not only a better answer but gives you many examples and sources of finding better event hooks.

    https://magento.stackexchange.com/a/167/336

    这篇关于如何在Magento中找到适合的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆