How to apply Patches on Magento 2

Lars Röttig
Aug 3, 2018 · 2 min read

Currently, there are two patches released for Magento CE 2.2.5.
In one of our projects we had the requirement to apply both patches.
In this case, I was searching for best practice to apply these patches on a Magento 2 Composer installation.


MAGETWO-93083 This patch provides performance optimization for retrieving product attributes in Magento 2.2.5


MAGETWO-93036 This patch provides a fix for problems that merchants experienced when trying to change a storefront’s applied theme in Magento 2.2.4 or 2.2.5. See GitHub-14968 for more information. Merchants who are running Magento 2.2.4 should upgrade to 2.2.5 and then apply this patch. Merchants who are running 2.2.5 should apply this patch or upgrade to 2.2.6 when it becomes available.


I found one article (Patch for a Magento 2 Composer installation) on the Magento 2 Support Side.
The recommendation with an extra composer package there is feasible solutions, but we want to limit how many composer dependencies a project has and also we don’t wish to have patch files in our build release for the production servers.

Our solution to patch

We create a patches folder outside from src.
In there we added the .patches files and a .sh file for every patch.
We add this file to our src/composer.json

Our project folder looks :

Content of CE-MAGETWO-93036–2018–07–02–07–06–53.sh

Our src/composer.json

Run composer install in your src folder.

Attention the post-install-cmd: occurs after the install command has been executed with a lock file present.


Lars Röttig

Written by

Developer @techdivision https://www.techdivision.com Maintainer Community Engineering Team @magento