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

查看:116
本文介绍了如何在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 我通常不会找到任何特定的足够grep它,我有依靠我的经验来识别可能的引导点。例如,当下订单时,我知道在某处经常有一个报价,或者可以通过付款对象来获得订单的参考,反之亦然。

    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.

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

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

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