我正在编写一个观察者函数,以便在下订单后添加我的自定义功能。我正在使用“sales_order_place_after”事件来执行此操作。我下订单后会插入这些值,但页面不会重定向到成功页面(表明已下订单)。如果我禁用我的模块或从配置中删除此事件,重定向工作正常。谁能告诉我哪里弄错了?
这是我的config.xml代码
<sales_order_place_after>
<observers>
<devengence_module_observer1>
<type>singleton</type>
<class>Devengence_Sugarcrm_Model_Observer</class>
<method>myFunction</method>
</devengence_module_observer1>
</observers>
</sales_order_place_after>
我的功能是
public function myFunction($observer){
$userOrdersModel=Mage::getModel("module/operations");
$userOrder=$userOrdersModel->load('OrderStatus');
echo "user Order is ".$userOrder;
if($userOrder->getId()) //// in case of update
{
$userOrdersModel->setId($observer->getEvent()->getOrder()->getStatus());
$userOrdersModel->setIsViewAllowed(0); //update the required value for enable and disable.
$userOrdersModel->save();
echo "User Order enable disable status updated";
}
else
{ // on new value insertion
$userOrdersModel->setId($observer->getEvent()->getOrder()->getStatus());
$userOrdersModel->setIsInsertAllowed(false);
$userOrdersModel->setIsUpdateAllowed(false);
$userOrdersModel->setIsDeleteAllowed(false);
$userOrdersModel->setIsViewAllowed(1);
$userOrdersModel->save();
echo "it does not exist, a new value has been entered in the database";
}
$userOrdersModel=Null;
$userOrder=Null;
}
执行此功能后,页面未重定向到成功页面。事件被触发后是否需要显式重定向?