0

I made changes to Magento Core files recently but those changes were overridden after a minor update to Magento CE 1.9.2.4 from version 1.9.2.3. 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?

  • Did you backup your store files before applying update? – Jayesh Patel Mar 14 '16 at 10:23
  • Yes, I have daily backup enabled on the servers. I can retrieve those files from the backup. I have auto-update enabled for my Magento Store for minor updates. I don't want my files to override each time Magento auto-updates. – Sumit Mar 14 '16 at 10:31
  • Great, kindly follow @Arunendra answer and make sure you always compare your core override files in future release as well Magento patch files. – Jayesh Patel Mar 14 '16 at 10:41
1

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 Product.php in 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 :

  1. 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.

  2. This approach is not magento upgrade friendly, because of the above reasons.

  3. 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.

  • Only core files that needs to be modified are those for generating Invoices in Magento, for Rupee symbol. As mentioned in your Answer, this method is not upgrade friendly. If I make relevant changes to the modified file after Magento update (updated core file), will that be fine? – Sumit Mar 14 '16 at 10:39
  • First of all never ever modify core files. just override the desired core file in local.After Magento updated it will not affect any thing. – Arunendra Mar 14 '16 at 10:43
  • In last reply, what I meant to ask is there might be a case there are changes made by Magento Team in core files that I might have earlier modified in local. To make those updates by Magento Team appear in my modified files, I can copy the new core file to local and make relevant changes to that file as per my requirements. I guess this way I can keep the latest updates from Magento for my store. – Sumit Mar 14 '16 at 10:47
  • @Sumit I have guided a way now it's depend on you, How you want to go. – Arunendra Mar 14 '16 at 10:57
  • Like how can i edit design file like app/design – Gem Apr 27 '18 at 6:03
0

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.

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.