0

is it possible to use magento core files as fallback?

Example: I really need to make a change in this file:

app/code/core/Mage/Core/Controller/Varien/Action.php

It will work if I create a copy at

app/code/local/Mage/Core/Controller/Varien/Action.php ?

Thanks!

2

Copying the app/code/core/Mage/Core/Controller/Varien/Action.php file to app/code/local/Mage/Core/Controller/Varien/Action.php should work. In Magento, there are 2 directories where controllers are placed; one is controllers and the other one is Controller (note the upper case and the singular).

The controllers (note the small case and plural) directory is used intentionally to prevent the classes inside this directory from being autoloaded.

Magento's autoloader will always capitalise the first letter after underscore and it'll expect such a directory to exist. In this case, whenever a class Mage_Core_Controller_Varien_Action is used, Magento will try to autoload the same by splitting the class name using underscore (_).

Hence this should work as expected. However if you try to use the same logic to override a controller from the controllers (note the small case and plural) directory, it will not work and you need to create a module to override it.

1

You cannot override controllers, you will need to make a module if you want your code to stay persistent when updates/patches are made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.