Magento 2.0.18 is the final 2.0.x release. After March 2018, Magento 2.0.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Import Magento EE into Magento Commerce (Cloud)

QUESTION: Do we really want to support a full overwrite?

The following instructions walk-through importing your Magento Commerce code into your current project code. When importing, you are force pushing your existing code in a Git repository over the Magento Commerce Cloud’s Git master branch.

Warning: When you force push code from an existing Git branch to your Magento Commerce Cloud project, you overwrite the project code in master. Any data, websites, stores, and so on will be lost. Before you continue, make sure there is nothing in your Magento Commerce Cloud project you want to keep.

Required information

Before you continue, make sure you have the encryption key from your Magento Commerce system.

Create a remote Git reference

This section discusses how to create a remote Git reference from your Cloud Git repository to the repository in which your Magento Commerce installation is located.

Before you continue, make sure you know the SSH or HTTPS URL for your Magento Commerce installation Git repository.

To create a remote Git reference:

  1. Log in to your local Magento Commerce Cloud development machine as, or switch to, the Magento file system owner.
  2. Make a copy of composer.json in a non-tracked directory so it doesn’t get overwritten.

       cp composer.json ../
  3. Rename your Cloud Git remote from origin to cloud-project to make it clear which repository is which:

    git remote rename origin cloud-project
  4. Add a remote upstream for your existing Magento Commerce installation:

    git remote add prev-project <git url>
  5. Confirm what you’ve done so far.

    git remote -v

    Results are displayed as follows.

    cloud-project (fetch)
    cloud-project (push)
    magento (fetch)
    magento (push)
    prev-project (fetch)
    prev-project (push)
  6. Make sure you’re on the Cloud project master branch.

    magento-cloud environment:checkout master
  7. Make sure this master branch is set up to import code to the Cloud project.

    git fetch cloud-project
    git branch -u cloud-project/master

Import your Magento Commerce code to your Cloud project

Before you continue, make sure you’ve completed all tasks discussed in the preceding section.

To import your Magento Commerce code to Cloud:

  1. Fetch the Magento Commerce branch.

    git fetch prev-project
  2. Reset your Cloud master branch to contain the code and the commit history of your Magento Commerce branch.

    git reset --hard prev-project/<branch name>
  3. Push code from your Magento Commerce project to your Magento Commerce Cloud project, overwriting the previous contents and commit history with that of your project.

    git push -f cloud-project master

    A successful deployment is indicated by the following messages:

    Re-deploying environment 43biovskhelhy-master-l5ut8gq.
       Environment configuration:
         mymagento (type: php:7.0, size: S, disk: 2048)
         mysql (type: mysql:10.0, size: S, disk: 2048)
         redis (type: redis:3.0, size: S)
         solr (type: solr:4.10, size: S, disk: 1024)
    Environment routes: is served by application `mymagento` is served by application `mymagento`

Import the Magento database

Before you can use your existing Magento Commerce code in Magento Commerce Cloud, you must import the database.

To import the Magento database in Magento Commerce Cloud, you must know:

  • The Magento Commerce Cloud environment’s SSH URL
  • The database name, username, and password of the Cloud database

This topic discusses how to import the Integration environment database. The database connection information is different for Staging and Production environments.

When importing data, you will need to drop and create a new database. If you have done any data you want to keep, create a backup of the database.

To drop and re-create the Cloud database:

  1. SSH to the Integration environment.

    magento-cloud ssh
  2. Connect to the database.

    mysql -h <db-host> -P <db-port> -p -u <db-user> <db-name>
  3. Drop the database. At the MariaDB [main]> prompt, enter:

    drop database main;
  4. Re-create the database:

    create database main;
  5. At the MariaDB [main]> prompt, enter exit.
  6. At the shell command prompt, enter the following command to re-create the database.

    zcat var/db.sql.tgz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h <db-host> -P <db-port> -p -u <db-user> <db-name>

    For example,

    zcat var/db.sql.tgz | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql -h database.internal -p -u user main

Update base URLs

Before you can access Magento from your local Cloud development system, you must change the Base URLs in the Magento database. Base URLs are stored in the core_config_data table.

The following example shows how to change only the insecure URL but you can use the same procedure to change secure URLs as well.

To update the unsecure base URL:

  1. If you haven’t already done so, SSH to the Cloud integration server.

        magento-cloud ssh
  2. Connect to the database.

    mysql -h <db-host> -P <db-port> -p -u <db-user> <db-name>
  3. Show the contents of the core_config_data table.

    SELECT * from core_config_data;

    Note the path of web/unsecure/base_url; this is the value you’ll change.

  4. Enter the following command to change the value of path to your integration server’s unsecure base URL:

    UPDATE core_config_data SET value='<Cloud unsecure base URL>' WHERE path='web/unsecure/base_url';

    The base URL must end with a / character.

  5. Confirm the change by entering the following command:

    SELECT * from core_config_data;
  6. If the change was successful, enter exit to exit the [Maria DB] prompt.
  7. Continue with the next section.

For your system to be fully functional, you must also set unsecure and secure URLs for the default scope as well as for all websites, stores, and store views.

Add the Magento encryption key

The Magento Commerce encryption key is required as an environment variable in env.php for Integration, Staging, and Production environments. If you deployed Magento when first creating a project across all environments, the encryption key should have been saved to env.php. If you have not deployed previously, you should verify and add the encryption key if needed in every environment. Without this key, the store encounters authentication and authorization errors such as payments and shipping.

You copied the key in a previous step.

To add your Magento Commerce encryption key:

  1. If you haven’t done so already, SSH to the Cloud environment.

    magento-cloud environment:ssh
  2. Open app/etc/env.php in a text editor.
  3. Replace the existing value of key with your Magento Commerce key.

    return array (
      'crypt' =>
      array (
        'key' => '<your encryption key>',
  4. Save your changes to env.php and exit the text editor.

    Make sure to add this key to the env.php file for all environments: Integration, Staging, and Production.

Import media

To import media files into your Cloud environment:

  1. If you haven’t done so already, SSH to the Cloud environment.

    magento-cloud ssh -p <project ID> -e <environment ID>
  2. Enter the following command to clear existing media files:

    rm -rf pub/media/*
  3. Enter the following command to extract the media files to the pub/media directory:

    tar -xzf var/media.tgz pub/media

Clear the cache

On the Cloud environment, enter the following commands in the order shown:

bin/magento setup:upgrade
bin/magento magento setup:static-content:deploy
bin/magento cache:clean

After the cache flushes, enter exit to close the SSH tunnel.

Verify the import

To verify everything imported properly, perform the following tasks in your local Cloud development environment:

  1. On your Cloud environment, enter the following commands to find the information to log in to the Magento Admin and to view the storefront:

    magento-cloud environment:url
  2. Log in to the Magento Admin using the username and password of your Magento Commerce system.
  3. Make sure settings in the Admin are the same as your Magento Commerce system.
  4. Access the storefront .
  5. Make sure categories, products, and so on display as you expect.
  6. Test everything thoroughly.