My custom module controller CartController.php's add method

public function addAction()
  $params = array(); //array of important data
  //here in event dispatcher, along with other data, i want to send $params to my even observer
  Mage::dispatchEvent('checkout_cart_add_product_complete', array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse()),$params);

My custom module's config.xml


Now, in my observer file Observer.php

 public function addToCartEvent($observer) {
       $params = Mage::app()->getFrontController()->getParams();
       print_r($params); //prints nothing

       //but this below is printing data
       $request = Mage::app()->getFrontController()->getRequest();
       print_r($request); //prints data

How do i pass this $param array from my controllers addAction method event dispatcher to my observer file ?

1 Answer 1


You can pass params like:

  Mage::dispatchEvent('checkout_cart_add_product_complete', array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse(),'my_params' => $params));

In the Observer method you can call

 public function addToCartEvent($observer) {
       $params = $observer->getMyParams()

The problem in your implementation was that you were passing $params to dispatchEvent array without a key. You need to add a key, like in my case I used my_params.

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.