DEV Community

Cover image for How to Apply a Magento 2 Patch
Amine Yaakoubi
Amine Yaakoubi

Posted on

How to Apply a Magento 2 Patch

Keeping your Magento 2 store secure and up-to-date is crucial for maintaining its stability and protecting it from vulnerabilities. In this guide, we’ll walk you through the steps to apply a Magento 2 patch, often referred to as a "composer patch," without actually using Composer.

Step-by-Step Guide to Applying a Magento 2 Patch

Step 1: Download the Patch

First, download the patch that is suitable for your Magento 2 version. Adobe regularly releases patches to address security vulnerabilities and other issues. For this example, we'll use the security update available for Adobe Commerce APSB24-40. You can find the relevant patch at the following link:

Adobe Commerce APSB24-40 Patch

Step 2: Unzip the Patch

Once you have downloaded the patch, unzip the file. The unzipped contents should include a file with a .composer.patch extension.

Step 3: Apply the Patch

To apply the patch manually, follow these steps:

  1. Navigate to your Magento root directory:
   cd /path/to/your/magento2/root
Enter fullscreen mode Exit fullscreen mode
  1. Apply the patch:
   patch -p1 < %patch_name%.composer.patch
Enter fullscreen mode Exit fullscreen mode

Replace %patch_name% with the actual name of the patch file you unzipped. For example, if the file is named VULN-27015-2.4.6x.composer.patch, you would run:

   patch -p1 < VULN-27015-2.4.6x.composer.patch
Enter fullscreen mode Exit fullscreen mode

Step 4: Verify the Patch

After applying the patch, it's important to verify that the patch was applied correctly and that your Magento store is functioning as expected. You can do this by:

  • Checking the patch log files for any errors.
  • Testing key functionalities of your store to ensure everything is working smoothly.
  • Running a security scan to confirm that the vulnerability addressed by the patch has been resolved.

Conclusion

Applying patches to your Magento 2 store is an essential part of maintaining its security and performance. By following these steps, you can ensure your store is protected against the latest vulnerabilities and continues to operate seamlessly.

For more detailed information and additional patches, always refer to the official Adobe Commerce knowledge base.

And that's it! You've successfully patched your Magento 2 store.

Top comments (2)

Collapse
 
mohamed_hattab_52c385f4ab profile image
Mohamed Hattab

Good job

Collapse
 
youssef_tabarki_ profile image
Youssef Tabarki

good work