Skip to content

Instantly share code, notes, and snippets.

@XigenDominic
Created April 28, 2021 19:58
Show Gist options
  • Save XigenDominic/65d282032c9f9f2756adc6fa53b54b70 to your computer and use it in GitHub Desktop.
Save XigenDominic/65d282032c9f9f2756adc6fa53b54b70 to your computer and use it in GitHub Desktop.
Create magento 2 custom patch
# Patcher
composer require cweagans/composer-patches
git add -f ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
# Edit file in vendor e.g. ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
mkdir ./patches
mkdir ./patches/composer
git diff ./vendor/magento/module-catalog/Model/ResourceModel/Product.php > ./patches/composer/skeleton.patch
git reset HEAD ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
# Undo change on file e.g. ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
# composer json
```
"extra": {
"magento-force": "override",
"composer-exit-on-patch-failure": true,
"patches": {
"magento/module-catalog": {
"Xigen import fix": "patches/composer/skeleton.patch"
}
}
}
```
composer install
```
composer install
Gathering patches for root package.
Removing package magento/module-catalog so that it can be re-installed and re-patched.
- Removing magento/module-catalog (103.0.5-p2)
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
- Installing magento/module-catalog (103.0.5-p2): Loading from cache
- Applying patches for magento/module-catalog
patches/composer/skeleton.patch (Xigen import fix)
```
Check file
@XigenDominic
Copy link
Author

Any tweaks to patch wording composer update --lock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment