Did something change about overriding code/core files with code/local?

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.

Solutions

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.

Similar questions

Something is overriding my onchange script?
I made a script that selects an option from a dropdown. The dropdown has onchange trigger and it trigger correctly when i run the script as a snippet (in a sandbox environment), but when i active the script on my Magento site the onchange script doesn't trigger? This is my code: I made a code snippet here: https://www.w3schools.com/code/tryit.asp?f...
How to Copy Code/Core system.xml file into Code/local in magento
i wanted some customization in admin panel so i have made changes in But I don't want to change code inside core folder. Because of my version change. So i like to move that file into my local folder but its not working Can anyone please guide me how to override system.xml file? Thanks
Add files to core or to local? (Not override)
I am installing the RedSys module http://www.redsys.es following their guide. At some point of their guide they say the following: 4.Se deben colocar los ficheros de la carpeta “Source”, incluido en el módulo de pago de REDSYS, en el siguiente directorio del módulo de Magento: (TRANSLATION: The Source folder's files must be included in the followin...
How to override abstract block app/code/core/Mage/Wishlist/Block/Abstract.php and app/code/core/mage/Controller/Abstract.php
In Controller Abstract.php file, I want to override the public function allcartAction() to add one more parameter to $item->addToCart($cart, $isOwner)) ie to change the function as $item->addToCart($cart, $isOwner,$params)) In Block/Abstract.php file I want to modify the public function getWishlistItems() { function to remove the visisbility fil...
In Magento ,is it possible to modify the default template files via custom modules without hacking into its *.phtml core files?
I am creating a custom module where i added a button in product view page(default file).I have inserted the button code in the following file and the button gets displayed & works well.But everytime Magento is updated , the above file gets replaced and so my code is discarded.Is there any way to modify or extend or inject the template coding fr...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.