【发布时间】:2013-11-26 17:22:30
【问题描述】:
我正在使用观察者来捕捉该事件:controller_action_postdispatch_checkout_onepage_saveBilling
我想要那个事件来检查客户的帐单地址。
我的问题是:此时我如何向用户发送消息。按下继续按钮时。
我使用的是:Mage::getSingleton('core/session')->addError('My message');
但在您刷新页面之前不会显示该消息。这是第二个问题。
我如何从那一点重定向页面?
我没有运气使用:$this->_redirect('*/*/'); 和没有运气的硬编码网址。
理想情况下,我希望当客户按下继续按钮时,在我进行一些检查后,通过一条消息停止该过程。检查观察者并且它按预期工作。
希望它有意义..
编辑 那是我的代码。只是为了确保我做对了: 模型/观察者
class Company_Restrictions_Model_Observer {
public function notifyUser($observer) {
//Lot's off lines are tested here.Nothing seems to work..
$observer->getRequest()->setParam('return_url','http://www.google.com/');
}
}
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Company_Restrictions>
<version>0.1.0</version>
</Company_Restrictions>
</modules>
<global>
<models>
<company_restrictions>
<class>Company_Restrictions_Model</class>
</company_restrictions>
</models>
<helpers>
<company_restrictions>
<class>Company_Restrictions_Helper</class>
</company_restrictions>
</helpers>
<events>
<controller_action_postdispatch_checkout_onepage_saveBilling>
<observers>
<notify_user>
<type>singleton</type>
<class>Company_Restrictions_Model_Observer</class>
<method>notifyUser</method>
</notify_user>
</observers>
</controller_action_postdispatch_checkout_onepage_saveBilling>
</events>
</global>
</config>
再次编辑
调试后我发现很多函数都给我错误。未定义的方法...例如:_redirect() 或 Response() 或 Body().. 有人知道为什么吗??
【问题讨论】:
标签: magento redirect magento-1.7 observers