Knowledgebase

How to override core files in Magento

When you modify the code of core Magento files these changes will be overwritten during an upgrade to a newer Magento version. It's a good idea to keep a list of all your code modifications so that if something happens you can make them again without forgetting any.

Instead of modifying core files, however, you can override those files that you need to change. As an example we'll assume that your store is installed directly in the public_html folder on your Magento hosting account (this makes the store accessible at yourdomain.com).

Let's say that you need to modify something on your site and this can be achieved by changing the code in public_html/app/code/core/Mage/Customer/Model/Address/Abstract.php. To override the file you need to go to public_html/app/code and create a folder called local. Then in the local folder you need to create a folder called Mage, inside it you should create a folder Customer and so on until the path corresponds to the original one and you end up with public_html/app/code/local/Mage/Customer/Model/Address. Then you need to copy the file Abstract.php from public_html/app/code/core/Mage/Customer/Model/Address and paste it in public_html/app/code/local/Mage/Customer/Model/Address. You can then make the necessary changes in the copied file in the local folder.

You can create directories and copy files from the Files section of the Pixie control panel, or you can use an FTP client (e.g. FileZilla).

Was this answer helpful?

 Print this Article

Also Read