Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 27th, 2012  |  syntax: None  |  size: 1.48 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In an Observer method, how do you tell Magento to not process code after the dispatched event
  2. public function checkForOrdKey(Varien_Event_Observer $observer)
  3.     {
  4.         $controllerAction = $observer->getControllerAction();
  5.         $request = $controllerAction->getRequest();
  6.         $controllerName = $request->getControllerName();
  7.         $stepData = $this->_getCheckoutSession()->getStepData();
  8.         $ordKeyRemoved = $this->_getCheckoutSession()->getOrdKeyRemoved();
  9.         // if it is the checkout onepage controller or inventory controller don't do anything
  10.         if (isset($controllerName) && $controllerName === "onepage" && $stepData['shipping']['complete'] && $ordKeyRemoved) {
  11.             $this->_getCheckoutSession()->setStepData('shipping', 'complete', false);
  12.             $result['goto_section'] = 'billing';
  13.             Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
  14.             $this->_getCheckoutSession()->setOrdKeyRemoved(false);
  15.  
  16.         }
  17.     }
  18.        
  19. $request = Mage::app()->getRequest();
  20. $action = $request->getActionName();
  21. Mage::app()->getFrontController()->getAction()->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
  22.        
  23. $response = Mage::app()->getResponse();
  24. $response->setHttpResponseCode(500);  //adjust to be whatever code is relevant
  25. $json = Mage::helper('core')->jsonEncode($this->__('Your message here'));  //adjust
  26. $response->setBody($json);
  27. //don't need to sendResponse() as the framework will do this later