Applying Magento 2 Security Patches Without Upgrading the Version
As an e-commerce developer, you may often find yourself working on Magento stores that are running older versions of the platform. While it’s always recommended to keep your software up-to-date for security and performance reasons, a full version upgrade can sometimes be challenging due to customizations or compatibility issues.
In this article, we will guide you through the process of applying the latest security patches to an existing Magento 2 installation without performing a major version upgrade. We’ll use the example of updating from version 2.3.4 to the patch level 2.3.7-p1.
Before You Begin: Backup Your Store
Before making any changes to your live site, it’s crucial to backup both your data and files. This ensures that you can easily revert if anything goes wrong during the process.
You can use tools like Magento Backup Suite or manually copy your app, pub, and database backups to a safe location on your server or local machine.
Downloading and Applying the Patch
-
Download the patch: Visit the official Magento 2 security patches page and download the
SUPEE-9767_EE_2.3.7_p1_v1.patchfile for version 2.3. -
Upload the patch to your server: Use an FTP client or SSH to upload this patch file into your Magento root directory (usually
/var/www/html/magento).
Applying the Patch via Command Line
The easiest way to apply a security patch is using the command line interface (CLI). Open your terminal, navigate to your Magento root folder and run:
cd /var/www/html/magento
Then, apply the patch with the following command:
patch -p1 < SUPEE-9767_EE_2.3.7_p1_v1.patch
This command applies the patch to your existing codebase while preserving your customizations.
Compile Static Files
After applying the patch, make sure to compile your static files for the changes to take effect:
bin/magento setup:static-content:deploy
This command will refresh all your CSS and JavaScript files based on the new file structure or added/removed elements.
Flush Cache
Finally, flush your Magento cache for the changes to be fully visible:
bin/magento cache:flush
Or if you prefer to use the user interface:
- Log in to your Magento backend.
- Navigate to
System > Cache Management. - Select all checkboxes and click
Flush Magento Cache.
Conclusion
By following these steps, you’ve successfully applied the latest security patch to your 2.3.4 installation without performing a major version upgrade.
Remember that while this method allows for quick patching, it’s still crucial to plan for regular upgrades at some point to ensure long-term stability and access to new features. Always test your store thoroughly after applying any patches or updates.
If you need help with larger migrations or custom development work, don’t hesitate to reach out to our team of Magento experts at Laravel Company.
Happy patching!