How to create a local copy of app/code/core/Mage/

Last modified by dd_gi on Fri, June 25, 2010 09:05
Source|Old Revisions  

This is an old revision of the document!


At times you may find that you will see a post in the Magento forums that recommends that you edit a “local” copy of a given Mangento core file such as app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php

The recommendation to edit a local copy of a core file is so that when you upgrade to a new version of Magento the core file you edited will be overwritten and you will lose your changes.

How the local folder works

Core files in the local folder override the same files in the core folder. For example, if you copy app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php to app/code/local/Mage/Catalog/Model/Layer/Filter/Price.php then Magento will use app/code/local/Mage/Catalog/Model/Layer/Filter/Price.php

The complication is that the app/code/local/* folders are not created by default, so if you would attempt to copy the file in an ssh session etc. the copy would fail since the enclosing folders have not been created.

How to create the local folder structure

You could just create folders as need, for example if you wanted to create a local copy of app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php you would first create the “/app/code/local/” folder if it did not exist, then inside app/code/local/ you would create a “Mage” folder and so on.

With PHP 5 and up you can create a complete directory structure with one mkdir command as it now has a recursive option.

To make that task easier I created a PHP script to duplicate the /app/code/core/Mage/ folder structure to /app/code/local/Mage/

Note that the script creates a folder only if it has not been created, if a local folder or subfolder exists now it does not create it nor does it modify any contents, it simply creates folders under /app/code/local/Mage/ if they do not exist.

How to use the script

First, create a new file named createlocal.php within your app/code/ folder within your Magento root folder. Copy the following code and paste into that file, then open it in a web browser.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs