在执行请求的控制器的方法之前如何调用方法:magento [英] How to call a method before the method of requested controller is executed : magento

查看:178
本文介绍了在执行请求的控制器的方法之前如何调用方法:magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在执行每个和每个控制器的方法之前调用一个方法。我不想去和每个方法调用方法。我只想从一个地方调用它,它将在magento中的任何控制器的任何方法之前被调用。



我相信我们可以做到这一点,



请提供您的建议。



希望我们可以解决这个问题,或者可能一些专家们已经解决了这个问题。



谢谢。

解决方案

需要创建一个Observer,绑定到 controller_action_predispatch 事件。这将在Magento代码库中的每个控制器之前触发。这里有一个有用的维基页面,让您了解处理。


I want to call a method before the execution of every and each controller's method. I don't want to go and call the method in every method. I just want to call it from one place and it will be called before any method of any controller in magento.

And I am sure we can do this but I don't know how it can be accomplished.

Please provide your suggestions.

Hope we can resolve this or may some expert guys already resolved this.

Thanks.

解决方案

You need to create an Observer that binds to the controller_action_predispatch Event. That will fire before every controller in the Magento codebase. There's a useful wiki page here that walks you through the process.

这篇关于在执行请求的控制器的方法之前如何调用方法:magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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