在所有Magento前端控制器actions [Magento]上挂钩之前



我想执行特定的操作

  • 进行外部API更新或
  • 重定向到另一个路径,等等

当要求使用特定get参数的任何前端URL。

e.g domain.com/checkout/cart?process=true

无论如何,我的模块是否可以检测到使用特定参数的请求?

您可以使用事件controller_action_predispatch。这在每个控制器的preDispatch方法中都称为
在观察者内部,您可以从$_GET获得任何参数:

$param = Mage::app()->getRequest()->getParam('param_name_here');

,您可以这样进行以下重定向:

Mage::app()->getFrontController()
    ->getResponse()
    ->setRedirect('URL GOES HERE')
    ->sendResponse();
exit; //it seams that this exit is important.

您需要编写一个观察者方法,然后在" controler_action_layout_load_before"中调用以获取参数。

最新更新