Magento Tutorial-How to Apply a Patch
This is an old revision of the document!
Sometimes Magento provides users with patches that fix certain issues and/or add some new functionality for previous versions.
Here is a brief tutorial on how you can install patches represented by .patch or .diff files. These files contain information about Magento files that should be changed/added and the lines of code that should be added to/removed from/changed in corresponding files.
Assume 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:
On this step you need to backup your current Magento installation i.e. copy it from the server on your local drive or another folder on server. For example: Magento was installed into /upandrunning 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.