Skip to main content

Here is my answer, i hope it will help someone:

First make sure that this package is installed via composer: cweagans/composer-patches

Lets say you want to apply a patch from a third-party module installed via composer for a controller. Please make sure that you have this part in the composer.json file:

"extra": {
    "magento-force": true,
    "composer-exit-on-patch-failure": true,
    "patches": {
        "vendorname/module-somerandomname": {
            "Description here": "patches/my_patch_name.patch"
        }
    }
},

Assuming that your vendor folder is in the .gitignore file, you can still do:

  1. git add -f vendor/vendorname/module-somerandomname/Controller/Myfile.php
  2. Do your changes to the Myfile.php
  3. Do a git diff vendor/vendorname/module-somerandomname/Controller/Myfile.php > patches/my_patch_name.patch
  4. git restorereset --stagedHEAD vendor/vendorname/module-somerandomname/Controller/Myfile.php
  5. Do a composer install

Here is my answer, i hope it will help someone:

First make sure that this package is installed via composer: cweagans/composer-patches

Lets say you want to apply a patch from a third-party module installed via composer for a controller. Please make sure that you have this part in the composer.json file:

"extra": {
    "magento-force": true,
    "composer-exit-on-patch-failure": true,
    "patches": {
        "vendorname/module-somerandomname": {
            "Description here": "patches/my_patch_name.patch"
        }
    }
},

Assuming that your vendor folder is in the .gitignore file, you can still do:

  1. git add -f vendor/vendorname/module-somerandomname/Controller/Myfile.php
  2. Do your changes to the Myfile.php
  3. Do a git diff vendor/vendorname/module-somerandomname/Controller/Myfile.php > patches/my_patch_name.patch
  4. git restore --staged vendor/vendorname/module-somerandomname/Controller/Myfile.php
  5. Do a composer install

Here is my answer, i hope it will help someone:

First make sure that this package is installed via composer: cweagans/composer-patches

Lets say you want to apply a patch from a third-party module installed via composer for a controller. Please make sure that you have this part in the composer.json file:

"extra": {
    "magento-force": true,
    "composer-exit-on-patch-failure": true,
    "patches": {
        "vendorname/module-somerandomname": {
            "Description here": "patches/my_patch_name.patch"
        }
    }
},

Assuming that your vendor folder is in the .gitignore file, you can still do:

  1. git add -f vendor/vendorname/module-somerandomname/Controller/Myfile.php
  2. Do your changes to the Myfile.php
  3. Do a git diff vendor/vendorname/module-somerandomname/Controller/Myfile.php > patches/my_patch_name.patch
  4. git reset HEAD vendor/vendorname/module-somerandomname/Controller/Myfile.php
  5. Do a composer install
Source Link
Attila Naghi
  • 4.1k
  • 4
  • 40
  • 76

Here is my answer, i hope it will help someone:

First make sure that this package is installed via composer: cweagans/composer-patches

Lets say you want to apply a patch from a third-party module installed via composer for a controller. Please make sure that you have this part in the composer.json file:

"extra": {
    "magento-force": true,
    "composer-exit-on-patch-failure": true,
    "patches": {
        "vendorname/module-somerandomname": {
            "Description here": "patches/my_patch_name.patch"
        }
    }
},

Assuming that your vendor folder is in the .gitignore file, you can still do:

  1. git add -f vendor/vendorname/module-somerandomname/Controller/Myfile.php
  2. Do your changes to the Myfile.php
  3. Do a git diff vendor/vendorname/module-somerandomname/Controller/Myfile.php > patches/my_patch_name.patch
  4. git restore --staged vendor/vendorname/module-somerandomname/Controller/Myfile.php
  5. Do a composer install