Magento Tutorial-How to Apply a Patch
At times, Magento provides users with patches which may contain fixes for certain issues and/or add new functionality to a particular version of Magento.
This brief tutorial details the instructions on how you can install patches (.sh, .patch, or .diff files) provided by Magento.
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.
Once you have downloaded the patch file related to your version of Magento, in order to successfully install it, you must follow the 4 steps outlined in this document.
Back up your current Magento installation. To do this, you just need to copy the folder from the local drive on another folder or server.
For the following example, Magento is installed in the /upandrunning directory/folder on the server. See screen shot below.
To backup your 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. See screenshot below.
This step is out of date. Newer patches have an .sh extension. To apply and revert .sh patches, see http://www.magentocommerce.com/knowledge-base/entry/apply-revert-magento-patches.
In the example below, our patch file is called 1420_patch.patch. Copy the patch file into the backup folder as shown in the screen shot below.
This step details the instructions for what you need to do in order to patch and test your system.
Use the following command to patch your system:
patch -p0 -i name_of_the_patch_file
NOTE: This command must be executed inside the target folder. This is the (/backup folder) in our example below:
NOTE: If the results show a conflict and/or in the case that some of the target files were not successfully patched, it can mean that you attempted to download and install a patch that is not relevant for our version of Magento.
downloaded patch is related to another Magento version - or it may be that you somehow changed the source code of corresponding files and it led to a conflict.
*Use the command below to revert the patch: patch -p0 -R -i name_of_the_patch_file
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.