0

I had written a observer to trap product view page event and it is working fine.Now i just want to load block from custom module controller without changing my current browser url so for that i am calling initForward() function with my custom module details but it is not working .The code for the try out is given below.

public function getProductView(Varien_Event_Observer $observer)
    {         
          $resp = $observer->getEvent()->getFront()->getAction()->getRequest();
          $requestUri = $resp->getRequestString();            
           if ($resp->getActionName() == 'noRoute'){
              $request = Mage::app()->getRequest();
              $request->initForward()
                ->setControllerName('index')
                ->setModuleName('customproduct')
                ->setActionName('index')
                ->setDispatched(false);
              return false;


           }
   }

1 Answer 1

0

As per my knowledege initForward() used in controller_action_predispatch event,,

You have to add event in you config.xml

 public function controllerActionPredispatch(Varien_Event_Observer $observer)
        {         

            if (your condition here) {
                $request = $controller->getRequest();
                $request->initForward();
                $request->setControllerName('index');
                $request->setModuleName('customproduct');
                $request->setActionName('index')
                ->setDispatched(FALSE);
            }
        }
2
  • can you please tell me how can i achieve it.
    – RickyN73
    Commented Jul 31, 2015 at 11:49
  • check my edit @RupeshDeotale
    – Keyur Shah
    Commented Jul 31, 2015 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.