Magento 1.7 – Extending Cart Controller for Specific Actions

extendmagento-1.7

I am trying to extend /checkout/cart/. I added "dumbAction" to test ensure the extension worked and /checkout/cart/dumb does work. However, when I access /checkout/cart I do not see any changes.

    <?php

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */

    require_once 'Mage/Checkout/controllers/CartController.php';

    class AimlessMedia_CheckoutActions_CartController extends Mage_Checkout_CartController
    /* the only reason this is extending the cart controller
     * is because I copied AimlessMedia_CheckoutDiscountOption and it
     * easier to just ride out the already programmed code
     */ {
        /**
         * Initialize coupon
         */
        public function dumbAction() {
            echo 'test indexAction';
        }
        public function indexAction() {
            echo ('test indexAction');
            parent::addAction();
        }
    }

Config.xml

0.1.0

<frontend>
    <layout>
        <updates>
            <AimlessMedia_CheckoutActions>
                <file>AimlessMedia_CheckoutActions.xml</file>
            </AimlessMedia_CheckoutActions>
        </updates>
    </layout> 
    <routers> 
        <checkout>
            <use>standard</use>
            <args>
                <module>AimlessMedia_CheckoutActions</module>
                <frontName>checkout</frontName>
            </args>
        </checkout>
    </routers>
</frontend>

<!-- the following allows our admin tab to link to a page and not return a 404 error -->
<adminhtml>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <CheckoutActions_options>
                                        <title>Shows Upsell Popup at Checkout</title>
                                    </CheckoutActions_options>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>

Resolution

Modified Config.xml to:

                <modules>
                    <CheckoutActions before="Mage_Checkout">AimlessMedia_CheckoutActions</CheckoutActions>
                </modules>

Best Answer

before="Mage_Checkout" tags missing

 <frontend>
            <routers>
                <checkout>
                    <args>
                        <modules>
                            <customcontacts before="Mage_Checkout">AimlessMedia_CheckoutActions</customcontacts>
                        </modules>
                    </args>
                </checkout>
            </routers>
        </frontend>  

try this a

see more details: http://www.amitbera.com/how-to-override-a-controller-in-magento/

Related Topic