I made changes to Magento Core files recently but those changes were overridden after a minor update to Magento CE 126.96.36.199 from version 188.8.131.52. Now I have to do those changes again. These are mandatory changes for my store and are required to make Rupee (Indian Currency) Symbol appear in Magento Invoices. Default Font does not support the symbol. How can I make those changes to stay permanent in the core file?
You can simply copy core file (which you want to override) and paste it in
app/code/local/Mage maintaining the same path of that php file. Then you can start editing this file, magento will read your file instead of the core file.
Below is an example :
=> If you would like to override
app/code/core/Mage/Catalog/Block/Product.php you need simply need it to put
app/code/local/Mage/Catalog/Block/Product.php. Doing only this will let magento read this file from local folder instead of core folder.
Reason for such behavior of reading from local folder to core folder is :
This process is called overriding Magento core functionality and is based on the fact that Magento sets its PHP include paths to first look in app/code/local/ then
app/code/community/ and finally in
app/code/core/. This has the effect that any files of the same name placed under the local or community name space will take precedence in loading, hence, we can override almost any core file in this way.
Demerits of Using Above Approach :
For one thing, we must override the complete core file and copy all the class functions. Once the overridden file is in place, this will be the file will be used instead of magento core file always. Given that most core classes contain several and many times a large number of methods it means that we are effectively overriding all those methods in our file.
This approach is not magento upgrade friendly, because of the above reasons.
This approach doesn’t work for controllers.
This approach is only useful while your testing/developing your module. Instead of writing a whole module, you can quickly override the core class see if things work well.
Avoid making changes to Magento Core files, you should try to overwrite it in your local pool itself. In that way when ever an upgrade is done your changes are not lost.