Magento Tutorial-How to Apply a Patch

Last modified by Rhonda Rondeau on Wed, September 14, 2011 10:09
Source|Old Revisions  

This is an old revision of the document!

At times, Magento provides users with patches that may fix certain issues and/or add new functionality for a particular version of Magento.

This brief tutorial details the instructions on how you can install patches provided by Magento in the form of a .patch or .diff file.

These files contain information about the Magento files that need to be changed/added and the lines of code that should be added to/removed from/changed in corresponding files.

For example: If you are using Magento and you have already downloaded a .patch (.diff) file related to your version from (assume the patch is named 1420_patch.patch).

In order to successfully install this patch you need to follow the next steps:

Step 1. Backup Current State

Back up your current Magento installation. (i.e. copy it from the server on your local drive or another folder on server.) For the following example, Magento is installed into the /upandrunning directory/folder on the server.

Copy the contents from this folder to another folder. (In the example below, we use the cp - r command to copy the contents of /upandrunning to /backup.

Step 2. Copy patch file into the backup folder

Step 3. Apply patch to the backup

On this step you need to patch your system and make sure that everything was fine. The command that will actually do all the work is: patch -p0 -i name_of_the_patch_file This command should be executed inside the target folder (/backup in our case). The result can look as following: If result shows conflicts or some of the target files were not successfully patched, it can mean that downloaded patch is related to another Magento version or you somehow changed the source code of corresponding files and it led to a conflict. *To revert the patch you can use the following command: patch -p0 -R -i name_of_the_patch_file

Step 4. Apply patch to the original Magento installation

If there were no conflicts on the step 3, you can now patch your original Magento installation. To do it, please make sure you have enough permissions to modify files in your Magento home directory (in our case it is /upandrunning folder) and perform actions described in Step 2 and Step 3 regarding it.

*At the end you should remove backup folder and the patch file from Magento home directory, because they are not needed anymore.