The following instructions show you how to upgrade using Composer. If your Adobe commerce current version is <2.4.1, you must first upgrade to a version that is compatible with Composer 2 (for example, 2.4.2) using Composer 1 before upgrading to Composer 2 for >2.4.2 upgrades. In addition, you must be running a supported version of PHP.
Before You Begin
Warning: May be you will not able to run magento command after update system requirements and other stuff, so
Run the following commands.
Step 1: Switch to maintenance mode.
php bin/magento maintenance:enable
Now: You must complete the prerequisites and system requirements to prepare enviroment before start the upgrade process.
Please check prerequisites on:
https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/prepare/prerequisites.html?lang=en
Manage packages
Create a backup of the composer.json file.
Run:
cp composer.json composer.json.bak
Create a backup of the composer.lock file.
Run:
cp composer.lock composer.lock.bak
The composer.lock file stores a set of exact version dependencies that satisfy all of the version constraints of every requirement for every package in the dependency tree of the project.
Now delete the composer.lock.
Now we are moving on to upgrade.
Step1: Add or remove specific packages based on your needs.
For example, if you are upgrading from Magento Open Source to Adobe Commerce, remove the Magento Open Source package.
Run:
composer remove magento/product-community-edition –no-update
OR if you are upgrading from Magento Enterprise Edition to Adobe commerce
Run:
composer remove magento/product-enterprise-edition –no-update
Step2: You can also upgrade sample data.
1 |
composer require <sample data module-1>:<version> ... <sample data module-n>:<version> --no-update |
Adobe commerce:
Run:
1 |
composer require magento/module-bundle-sample-data:100.4.* magento/module-widget-sample-data:100.4.* magento/module-theme-sample-data:100.4.* magento/module-catalog-sample-data:100.4.* magento/module-customer-sample-data:100.4.* magento/module-cms-sample-data:100.4.* magento/module-catalog-rule-sample-data:100.4.* magento/module-sales-rule-sample-data:100.4.* magento/module-review-sample-data:100.4.* magento/module-tax-sample-data:100.4.* magento/module-sales-sample-data:100.4.* magento/module-grouped-product-sample-data:100.4.* magento/module-downloadable-sample-data:100.4.* magento/module-msrp-sample-data:100.4.* magento/module-configurable-sample-data:100.4.* magento/module-product-links-sample-data:100.4.* magento/module-wishlist-sample-data:100.4.* magento/module-swatches-sample-data:100.4.* magento/sample-data-media:100.4.* magento/module-offline-shipping-sample-data:100.4.* magento/module-gift-card-sample-data:100.4.* magento/module-customer-balance-sample-data:100.4.* magento/module-target-rule-sample-data:100.4.* magento/module-gift-registry-sample-data:100.4.* magento/module-multiple-wishlist-sample-data:100.4.* --no-update |
OR
Magento Open Source:
Run:
1 |
composer require magento/module-bundle-sample-data:100.4.* magento/module-widget-sample-data:100.4.* magento/module-theme-sample-data:100.4.* magento/module-catalog-sample-data:100.4.* magento/module-customer-sample-data:100.4.* magento/module-cms-sample-data:100.4.* magento/module-catalog-rule-sample-data:100.4.* magento/module-sales-rule-sample-data:100.4.* magento/module-review-sample-data:100.4.* magento/module-tax-sample-data:100.4.* magento/module-sales-sample-data:100.4.* magento/module-grouped-product-sample-data:100.4.* magento/module-downloadable-sample-data:100.4.* magento/module-msrp-sample-data:100.4.* magento/module-configurable-sample-data:100.4.* magento/module-product-links-sample-data:100.4.* magento/module-wishlist-sample-data:100.4.* magento/module-swatches-sample-data:100.4.* magento/sample-data-media:100.4.* magento/module-offline-shipping-sample-data:100.4.* --no-update |
Step3: Now check composer.json if you have magento-cloud-metapacka
Run:
composer require “magento/magento-cloud-metapackage”:”2.4.5″ –update-with-dependencies
Step4:
Adobe commerce or Enterprise Edition
Run:
composer require-commerce magento/product-enterprise-edition 2.4.5-p1 –no-update
Magento Open Source:
Run:
composer require-commerce magento/product-community-edition 2.4.5-p1 –no-update
Step5:
Run:
composer update -vvv
and output will be something like below screenshot:
Unfortunately if got error:
PHP Fatal error: During inheritance of Countable: Uncaught Exception: Deprecated Functionality: Return type of Composer\Repository\CompositeRepository::count() should either be compatible with Countable::count(): int,
Reference link: https://stackoverflow.com/questions/71998726/when-i-upgrading-magento-2-4-4-i-am-getting-deprecated-functionality-return-typ
just update the composer.json with this packages in require
1 2 3 4 |
"require": { "magento/composer-dependency-version-audit-plugin": "~0.1", "magento/composer-root-update-plugin": "^2.0", }, |
Run again
Composer update
Step6: Clear cache and regenerate code.
You can get a number of errors due to upgrade process, While you will regenerating code and running below commands. So you have to solve the errors one by one.
Run:
1 2 3 4 5 6 7 8 9 |
php bin/magento cache:clean rm -rf var/cache/* rm -rf var/page_cache/* rm -rf generated/code/* php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento cache:flush php bin/magento cache:clean |
Last but not least, remember to turn off maintenance mode.
Run:
php bin/magento maintenance:disable
bluethinkinc_blog
2022-10-27