【问题标题】:Magento: Find observers for dispatched events?Magento:查找已调度事件的观察者?
【发布时间】:2011-10-12 11:51:56
【问题描述】:

我需要找出调度以下事件时触发的方法

   Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));

我知道如何创建自定义事件挂钩并且它应该保留在 config.xml 中,但是我在任何配置 XML 中都找不到这个 sales_qute_add_item 的挂钩。

【问题讨论】:

    标签: events magento hook observer-pattern


    【解决方案1】:

    没关系。 Magento 中没有此事件的默认侦听器。 Magento 核心团队专门为自定义目的添加了此事件。

    【讨论】:

      【解决方案2】:

      这样做

      <events>
          <sales_quote_add_item>
              <observers>
                  <your_observer_name>
                      <type>model</type>
                      <class>Your_Observer_Class</class>
                      <method>yourObserverMethod</method>
                  </your_observer_name>
              </observers>
            </sales_quote_add_item>
      </events>
      

      【讨论】:

        【解决方案3】:

        只需在所有配置 xml 文件中搜索

        <sales_quote_add_item>
        

        如果它在 events 标记中,则查看方法和类以查看它在哪个文件中。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-03-23
          • 2016-11-01
          • 2012-10-19
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多