How to redirect from Observer
in Magento2
? I am using the below code:
$controller = $observer->getControllerAction();
$action = $this->_request->getActionName();
$this->_actionFlag->set($action, \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$controller->getResponse()->setRedirect('sales/order/address', array('address_id' => $addressId));
return $this;
event.xml
<event name="controller_action_predispatch_sales_order_addressSave">
<observer name="verify_cod" instance="XXX\Ccc\Observer\Pincode" />
</event>