Magento Tutorial-How to Apply a Patch
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 www.magentocommerce.com (assume the patch is named 1420_patch.patch).
In order to successfully install this patch you need to follow the next steps:
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.
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.