1

As demonstrated in this 4 year old document on Magento's site: https://wiki.magento.com/pages/viewpage.action?pageId=10223961

I've used this method in past years and it has worked. Copy directory path and specific file you would like to overwrite to the same location but in "local" instead of "core". Now I'm seeing information that states otherwise and it definitely isn't working in CE 1.9.

https://stackoverflow.com/questions/7110042/cant-seem-to-override-checkout-controller-in-magento

Note: CartController.php is the file/controller I'm working with.

2

1 Answer 1

3

This is a crappy custom. You need to avoid this. A magento developer should follow best practises.

As per the best practices, if you need to extend or modify a core controller method, then you should rewrite that core controller class with a simple extension. Again if you can utilize any event to do the task, then you should give preference to the observer event.

Follow this post for getting familiarize with how to do a rewrite.

For an example, you can rewrite CartController.php like this.

File : app\code\local\Namespace/Module/etc/config.xml

<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <namespace_module before="Mage_Checkout">Inchoo_Tag</namespace_module>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

and now you should define rewrite class for CartController inside your module.

File : app\code\local\Namespace/Module/controllers/CartController.php

<?php
require_once(Mage::getModuleDir('controllers','Mage_Checkout').DS.'CartController.php');

class Namespace_Module_TagController extends Mage_Checkout_CartController
{
    // your custom rewrite codes comes here
}

That's it. Remember always follow magento best practices.

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.