【问题标题】:Magento - Last event name that is executed after a page is loadedMagento - 加载页面后执行的最后一个事件名称
【发布时间】:2011-08-30 04:29:34
【问题描述】:

在我的自定义模块中,我在会话变量和controller_action_layout_render_before 事件中设置了一个标志,检查是否设置了标志,然后附加自定义内容。

我想在页面加载后取消设置会话变量中的标志。

怎么做。

页面加载时是否有任何事件在最后执行?

【问题讨论】:

    标签: events magento observer-pattern


    【解决方案1】:

    controller_front_send_response_after
    

    事件应该适合你。暂时添加一些日志到app/Mage.php

    public static function dispatchEvent($name, array $data = array())
    {   
        //Mage::Log($name);                 
        file_put_contents('/tmp/event.log',"$name\n",FILE_APPEND);    
    
        Varien_Profiler::start('DISPATCH EVENT:'.$name);
        $result = self::app()->dispatchEvent($name, $data);
        #$result = self::registry('events')->dispatch($name, $data);
        Varien_Profiler::stop('DISPATCH EVENT:'.$name);
        return $result;
    }
    

    可以为您获取针对特定请求触发的事件列表,这通常足以追踪您自己正在寻找的事件。

    【讨论】:

      【解决方案2】:

      您希望仅在单个请求的生命周期内存储变量,您可以考虑使用 Magento 的注册表。基本上,您使用Mage::register('some_variable_name',$variable); 插入一个值,然后在使用Mage::registry('some_variable_name'); 的同一请求中的其他上下文中检索它

      有关更多信息,请参阅@Alan Storm 的回答 here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-01-23
        • 2011-09-02
        • 1970-01-01
        • 2012-02-18
        • 1970-01-01
        • 1970-01-01
        • 2017-06-08
        • 1970-01-01
        相关资源
        最近更新 更多