即使客户没有登录,我也想在客户需要添加报价和产品详细信息的自定义页面上重定向客户。当他从产品视图页面单击“添加到比较”链接时,他将在此页面上重定向,并且在提交表单后,他将保持原样并显示成功消息。
请注意,这件事我必须从索引控制器的 preDispatch 功能中完成。谢谢你。
即使客户没有登录,我也想在客户需要添加报价和产品详细信息的自定义页面上重定向客户。当他从产品视图页面单击“添加到比较”链接时,他将在此页面上重定向,并且在提交表单后,他将保持原样并显示成功消息。
请注意,这件事我必须从索引控制器的 preDispatch 功能中完成。谢谢你。
您需要在 config.xml 中添加代码
<frontend>
<events>
<controller_action_predispatch>
<observers>
<controller_action_before>
<class>dispatcher/observer</class>
<method>controllerActionPreDispatch</method>
</controller_action_before>
</observers>
</controller_action_predispatch>
</events>
</frontend>
在 model/observer.php 文件中添加代码
public function controllerActionPreDispatch($observer)
{
//we compare action name to see if that's action for which we want to add our own event
if($observer->getEvent()->getControllerAction()->getFullActionName() == 'yourmodule Action Name')
{
Mage::app()->getResponse()->setRedirect(Mage::getUrl("customer/account"));
}
}