Stratus Magento 2 Guides - Upgrade Recommendations
The following are helpful guides for upgrading Magento 2.x.
Support for upgrading Magento 2 is outside the scope of regular support.
Before Upgrading
Perform a local backup of the files and database before upgrading. Test the upgrade first on a development environment before performing the same steps on production.
- Disable crons temporarily
- Put the site in maintenance mode
Notes about Upgrading higher than Magento 2.4.3+
- During setup:upgrade you may get an error related to ServiceManager.php:
Service with name "Magento\Setup\Console\Command\DbStatusCommand" could not be created. Reason: Class "Vertex\Tax\Setup\Schema\Triggers\MigrateVertexInvoiceSent" does not exist
. This is because the Vertex module does not exist in Magento 2.4.4 & higher. You can solve this issue by clearing caches and running setup:upgrade again.
redis-cli -h redis flushall && redis-cli -h redis-session -p 6380 flushall && redis-cli -h redis-config-cache -p 6381 flushall;stratus cache.all.clear
- During setup:upgrade you may get an error in logs related to DataObject.php:
main.CRITICAL: Deprecated Functionality: Return type of Magento\Framework\DataObject::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /cache/vendor/magento/framework/DataObject.php
In this case you will need to do the following:
- While PHP version is set to 7.4:
composer require magento/composer-root-update-plugin ~2.0 --no-update
composer update
rm -rf var/cache/* ; rm -rf var/page_cache/* ; rm -rf generated/code/* ; php bin/magento setup:upgrade
composer require-commerce magento/product-community-edition 2.4.4 --no-update
composer update
- CHANGE TO PHP 8.1:
rm -rf var/cache/* ; rm -rf var/page_cache/* ; rm -rf generated/code/* ; php bin/magento setup:upgrade
Upgrading to a Major Release
To upgrade to 2.2.7 (in this example), run:
composer require magento/product-community-edition 2.2.7 --no-update
php -d memory_limit=4096M /usr/local/bin/composer update
php -d memory_limit=4096M /usr/local/bin/composer -v install
php -d memory_limit=4096M bin/magento setup:upgrade
php -d memory_limit=4096M bin/magento setup:di:compile
php -d memory_limit=4096M bin/magento setup:static-content:deploy
For more information, see Magento’s upgrade documentation.
Upgrading to 2.3.x Using the Magento script
wget https://raw.githubusercontent.com/magento/magento2/2.3/dev/tools/UpgradeScripts/pre_composer_update_2.3.php
php -f pre_composer_update_2.3.php -- --root=/srv/public_html --repo=https://repo.magento.com/ --version=2.3.3
php -d memory_limit=4096M /usr/local/bin/composer update
php -d memory_limit=8000M bin/magento setup:upgrade
php -d memory_limit=4096M bin/magento setup:di:compile
php -d memory_limit=4096M bin/magento setup:static-content:deploy
For more information, please see Magento’s upgrade documentation.
If you receive an error about Magento credentials, run
composer update
. This will prompt you for your credentials. Choose “Y” to save them to your project.
Upgrading from 2.3.x to 2.4.x
-
Ask Stratus Support to upgrade MySQL to a minimum of version 5.7.
-
Enable Elasticsearch 7 in the STRATUS panel (it will redeploy upon change)
-
Confirm that PHP is version 7.3+ (it will also redeploy upon change)
php -d memory_limit=4096M /usr/local/bin/composer require magento/composer-root-update-plugin=~1.0 --no-update php -d memory_limit=8000M /usr/local/bin/composer update php -d memory_limit=4096M /usr/local/bin/composer require magento/product-community-edition=2.4.3 --no-update --interactive-magento-conflicts php -d memory_limit=8000M /usr/local/bin/composer update php -d memory_limit=4096M bin/magento setup:upgrade php -d memory_limit=4096M bin/magento setup:di:compile php -d memory_limit=4096M bin/magento setup:static-content:deploy
After Upgrading
- Re-enable crons.
- Take the site out of maintenance mode.
- Clear all caches
- Perform an autoscaling reinit or ZDD commands if Zero Downtime Deployment is enabled.
Feedback
Was this page helpful?
Glad to hear it! Have any more feedback? Please share it here.
Sorry to hear that. Have any more feedback? Please share it here.