3

I want to influence product rendering (passing $params to Mage_Catalog_Helper_Product_View::prepareAndRender()) and registered an observer on the controller_action_predispatch_catalog_product_viewevent.

rendering is working fine, but the original catalog/product/view action is still executed and so two products are displayed.

How can I stop the dispatching during the pre-dispatch observer?

tereško
  • 58,060
  • 25
  • 98
  • 150
Alex
  • 32,506
  • 16
  • 106
  • 171

1 Answers1

9
  1. the dispatched field of the request has to be true
  2. the FLAG_NO_DISPATCH flag of the front action has to be set to true

In code (inside observer):

// @see Mage_Core_Controller_Varien_Action::dispatch()
$controller = $observer->getControllerAction();
$controller->getRequest()->setDispatched(true);
$controller->setFlag(
    '', 
    Mage_Core_Controller_Front_Action::FLAG_NO_DISPATCH, 
    true
);
Alex
  • 32,506
  • 16
  • 106
  • 171