Upgrade Magento version
You can upgrade the core Magento Commerce code base to a newer version. Before upgrading your project, review the Magento Commerce Cloud service versions information for the latest software version requirements. If you need to upgrade from a version older than 2.1, you must upgrade to a supported version first. See Upgrades and patches for upgrade path details.
Before beginning an upgrade or a patching process, create an active branch from the Integration environment and checkout the new branch to your local workstation. Dedicating a branch to the upgrade or the patch process helps to avoid interference with your work in progress.
If you use a version of Magento Commerce Cloud that does not contain the ece-tools
package, then you must upgrade your project. If you currently use the ece-tools package and you need to update it, see Update ece-tools version.
Upgrade from older versions of the Magento application
Review the Magento Commerce Cloud service versions information for the latest software version requirements. Your upgrade tasks may include the following:
- Update your PHP version Elasticsearch version, and other services
- Convert an older configuration management file
- Update the
.magento.app.yaml
file with new settings for hooks and environment variables - Upgrade third-party extensions to the latest supported version
- Update the
.gitignore
file
If you upgrade the PHP version, you must also submit a Support ticket to update the New Relic service.
Configuration management
If you are upgrading from 2.1.4 or later to 2.2.x or later and use Configuration Management, you need to migrate the config.local.php
file. Older versions used a config.local.php
file for Configuration Management, but version 2.2.0 and later use the config.php
file. This file works exactly like the config.local.php
file, but it has different configuration settings that include a list of your enabled modules and additional configuration options.
To create a temporary config.php
file:
-
Create a copy of
config.local.php
file and name itconfig.php
. -
Add this file to the
app/etc
folder. -
Add and commit the file to your branch.
-
Push the file to your Integration branch.
-
Continue with the upgrade process.
After upgrading, you can remove the config.php
file and generate a new, complete file. You can only delete this file to replace it this one time. After generating a new, complete config.php
file, you cannot delete the file to generate a new one. See Configuration Management and Pipeline Deployment.
Update the configuration file
If you are upgrading from an older version of Magento to 2.2.x or later, you must also update your .magento.app.yaml file or you might encounter errors. Magento Commerce Cloud 2.2.x and later has new settings in the file.
To update the .magento.app.yaml
file:
-
Update the PHP options.
1
type: php:<version>
-
Modify the hook commands in the
magento.app.yaml
file.1 2 3 4 5 6 7 8 9 10 11 12
hooks: # We run build hooks before your application has been packaged. build: | set -e php ./vendor/bin/ece-tools build:generate php ./vendor/bin/ece-tools build:transfer # We run deploy hook after your application has been deployed and started. deploy: | php ./vendor/bin/ece-tools deploy # We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10. post_deploy: | php ./vendor/bin/ece-tools post-deploy
-
Add the following environment variables to the end of the
magento.app.yaml
file.1 2 3 4 5
variables: env: CONFIG__DEFAULT__PAYPAL_ONBOARDING__MIDDLEMAN_DOMAIN: 'payment-broker.magento.com' CONFIG__STORES__DEFAULT__PAYMENT__BRAINTREE__CHANNEL: 'Magento_Enterprise_Cloud_BT' CONFIG__STORES__DEFAULT__PAYPAL__NOTATION_CODE: 'Magento_Enterprise_Cloud'
-
Save the file. Do not commit or push changes to your branch yet.
-
Continue with the upgrade process.
Verify Zend Framework composer dependencies
When upgrading to 2.3.x or later from 2.2.x, verify that the Zend Framework dependencies in the autoload
property of the composer.json
file have been updated with the Laminas plugin. This plugin supports new requirements for the Zend Framework, which has migrated to the Laminas project. See Migration of Zend Framework to the Laminas Project on the Magento DevBlog.
To check and update Zend Framework dependencies:
-
On your local workstation, change to the Cloud project root directory.
-
Checkout your integration branch.
-
Open the
composer.json
file in a text editor. -
Check the
autoload:psr-4
section for the Laminas plugin:1 2 3 4 5 6 7
"autoload": { "psr-4": { "Magento\\Framework\\": "lib/internal/Magento/Framework/", "Magento\\Setup\\": "setup/src/Magento/Setup/", "Magento\\": "app/code/Magento/", + "Laminas\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/" },
-
If the Laminas plugin is missing, update
composer.json
:-
Add the following line to the
autoload:psr-4
section.1
"Laminas\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
-
Update the project dependencies.
1
composer update
-
Add, commit, and push code changes.
1
git add -A
1
git commit -m "Add Laminas plugin to Zend Framework composer dependencies"
1
git push origin <branch-name>
-
Merge changes to the Staging environment, and then to Production.
-
Upgrade the Magento application
Review the service versions information for the latest software version requirements before upgrading your Magento application.
For Pro projects, you must create a Support ticket to install or update services in Staging and Production environments. Indicate the service changes needed and include your updated .magento.app.yaml
and services.yaml
files in the ticket. It can take up to 48 hours for the Cloud infrastructure team to update your project.
Back up the database
We recommend creating a backup of your project before an upgrade. Use the following steps to back up your Integration, Staging, and Production environments.
To back up your Integration environment database and code:
-
Create a local backup of the remote database.
1
magento-cloud db:dump
The
magento-cloud db:dump
command runs the mysqldump command with the--single-transaction
flag, which allows you to back up your database without locking the tables. -
Back up code and media.
1
php bin/magento setup:backup --code [--media]
Optionally, you can omit
[--media]
if you have a large number of static files that are already in source control.
To back up your Staging or Production environment database before deploying:
-
Use SSH to log in to the remote server.
-
Create a database dump.
1
vendor/bin/ece-tools db-dump
The dump operation creates a
dump-<timestamp>.sql.gz
archive file in your remote project directory. See Snapshot and backup management.
Complete the upgrade
To upgrade the Magento version:
-
Change to your Magento root directory and set the upgrade version using the version constraint syntax.
1
composer require "magento/magento-cloud-metapackage":">=CURRENT_VERSION <NEXT_VERSION" --no-update
You must use the version constraint syntax to successfully update the
ece-tools
package. You can find the version constraint in thecomposer.json
file for the version of the Magento application template you are using for the upgrade. -
Update the project.
1
composer update
-
Add, commit, and push code changes.
1
git add -A
1
git commit -m "Upgrade"
1
git push origin <branch-name>
git add -A
is required to add all changed files to source control because of the way Composer marshals base packages. Bothcomposer install
andcomposer update
marshal files from the base package (magento/magento2-base
andmagento/magento2-ee-base
) into the package root.The files that Composer marshals belong to the new version of Magento, to overwrite the outdated version of those same files. Currently, marshaling is disabled in Magento Commerce, so you must add the marshaled files to source control.
-
Wait for deployment to complete.
-
Verify the upgrade in your Integration, Staging, or Production environment by using SSH to log in and check the version.
1
php bin/magento --version
Create a new config.php file
As mentioned in Configuration management, after upgrading, you need to create an updated config.php
file. Complete any additional configuration changes through the Magento Admin in your Integration environment.
To create a system-specific configuration file:
-
From the terminal, use an SSH command to generate the
/app/etc/config.php
file for the environment.1
ssh <SSH-URL> "<Command>"
For example for Pro, to run the
scd-dump
on theintegration
branch:1
ssh <project-id-integration>@ssh.us.magentosite.cloud "php vendor/bin/ece-tools config:dump"
-
Transfer the
config.php
file to your local workstations usingrsync
orscp
. You can only add this file to the branch locally.1
rsync <SSH-URL>:app/etc/config.php ./app/etc/config.php
-
Add, commit, and push code changes.
1
git add app/etc/config.php && git commit -m "Add system-specific configuration" && git push magento master
This generates an updated
/app/etc/config.php
file with a module list and configuration settings.
For an upgrade, you delete the config.php
file. Once this file is added to your code, you should not delete it. If you need to remove or edit settings, you must edit the file manually.
Upgrade extensions
Review your third-party extension and module pages in Marketplace or other company sites to verify support for Magento Commerce and Magento Commerce Cloud. If you need to upgrade any third-party extensions and modules, we recommend working in a new Integration branch with your extensions disabled.
To verify and upgrade your extensions:
-
Create a new branch on your local workstation.
-
Disable your extensions as needed.
-
When available, download extension upgrades.
-
Install the upgrade as documented by the third-party documentation.
-
Enable and test the extension.
-
Add, commit, and push the code changes to the remote.
-
Push to and test in your Integration environment.
-
Push to the Staging environment to test in a pre-production environment.
We strongly recommend upgrading your Production environment before including the upgraded extensions in your site launch process.
When you upgrade your Magento version, the upgrade process updates to the latest version of the Fastly CDN module for Magento 2 automatically.
Troubleshoot upgrade
If the upgrade failed, you receive an error message in the browser indicating that you cannot access your storefront or the Magento Admin panel:
1
2
3
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: <error-number>
To resolve the error:
-
Using SSH, log in to the remote server and open the
./app/var/report/<error number>
file. -
Examine the logs to determine the source of the issue.
-
Add, commit, and push code changes.
1
git add -A && git commit -m "Fixed deployment failure" && git push magento <branch-name>