How do i override the “addAction()” funciton under appcodecoreMageCheckoutcontrollers

I am trying to add some data to a session variable when a product is added to the shopping cart…

I tried copying the “CartController.php” under “appcodecoreMageCheckoutcontrollers” to
“localMageCheckoutcontrollers” but its not actually overriding the controller..

Could anyone give me some hint on this..?

Thanks a lot.

2 thoughts on “How do i override the “addAction()” funciton under appcodecoreMageCheckoutcontrollers”

  1. You can create an “Event Oberserver” to trigger an event.

    Create the following folders :

    • app/code/local/[myMagento]/EventTest/etc
    • app/code/local/[myMagento]/EventTest/Model

    create a file under /EventTest/Model directory like myMagento_EventTest.xml and put the following :

    <?xml version="1.0"?>

    create config.xml file under /EventTest/etc folder nad put the following :

    <?xml version="1.0"?>

    create model class file observer.php under the /EventTest/Model directory and put following

    class myMagento_EventTest_Model_Observer {
    public function MyTestMethod($observer) {
    $event = $observer->getEvent(); //Fetches the current event
    $product = $event->getProduct();
    $eventmsg = "Current Event Triggered : " . $event->getName() . "
    Currently Added Product : " . $product->getName();
    //Adds Custom message to shopping cart
    echo Mage::getSingleton("checkout/session")->addSuccess($eventmsg);
    //Your Custom Logic Here
    //you can use print_r($product) here to get more details

  2. I found this , this enables us to override the CartController.php addAction() funciton… This is exaclty i needed.

    Hope this would help someone in need.


Leave a Reply

Your email address will not be published. Required fields are marked *