Import existing code into a project

When first creating your Magento Commerce (Cloud) project, you may have a choice of a blank template or importing existing code. We highly recommend always starting with a blank template to receive the Magento Commerce (Cloud) codebase to build on. You can start adding your existing Magento custom code, extensions and modules, themes, and more to development branches created from .

For trial Starter and Pro projects, we automatically provision your project with the latest version of Magento Commerce (Cloud). You do not have an option of creating a project by importing. Not to worry, if you still want to fully import your existing codebase and overwrite the Git master branch for your project, these instructions will walk through the process.

These instructions primarily include information and instructions to import existing Magento code and data into a blank Magento Commerce (Cloud) template project.

If you have the option of creating a project using existing code,

Prerequisites for importing code

Before you continue, make sure you have done all of the following:

  • Your existing Magento Commerce code must be in Git. You need to have a Git account with a repository and your code added to it. If you do not have this set up, we recommend using GitHub. You must have a Git branch with your code pushed to it before continuing with these instructions.
  • You should have a fully installed and configured local development environment. For details, follow the instructions for Local environment setup.

Required information for your import

You need to locate and gather the information required information to import Magento Commerce into Magento Commerce (Cloud), including:

  • SSH access to the cloud environment for the target database
  • Database credentials

SSH access to cloud environments

To transfer the database dump and files to Magento Commerce (Cloud), you must know the SSH URL. You can locate the SSH access using the CLI or Project Web Interface:

  • On your local, you can locate the SSH information using the command: magento-cloud environment:ssh --pipe
  • The Project Web Interface.

You must enter all Magento Commerce (Cloud) commands on the machine on which your Cloud SSH keys are stored. For more information, see Enable SSH keys and SSH and sFTP.

Database credentials

Collect the credentials for your databases.

For the Magento Commerce database, you need the name of the database and user credentials (username and password) to access the database.

For the Magento Commerce (Cloud) database, you need credentials and data for the cloud database to import your data. The name of the database can be found in the $MAGENTO_CLOUD_RELATIONSHIPS environment variable.

To find Magento Commerce (Cloud) database access information:

  1. SSH to into your environment:

     magento-cloud ssh -p <project ID> -e <environment ID>
  2. Use the following command to list all database information:

     echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp

The database connection information is displayed:

database" : [
         "username" : "user",
         "query" : {
            "is_master" : true
         "path" : "main",
         "port" : 3306,
         "host" : "database.internal",
         "password" : "",
         "scheme" : "mysql",
         "ip" : ""

This information provides the following: the database name is main, its listen port is 3306, its host name is database.internal, its root user name is user, and the user has no password.

Cloud unsecure base URL

After you import the Magento Commerce database into Magento Commerce (Cloud), you must change the base URL so you can access the Magento Admin and storefront.

Locate the base URL:

Import workflow for existing code

The complete workflow for importing existing code includes the following steps.

  1. If you do not have a project created and available, create a new project from a template. This new project has files and directories specific to Magento Commerce (Cloud).
  2. Replace the contents of this project with your code using Git.
  3. Import your Magento database into your Magento Commerce (Cloud) project.
  4. Import your static files into your Magento Commerce (Cloud) project.
  5. Copy your Magento Commerce encryption key to your Magento Commerce (Cloud) project. This key is required for data migration and access.
  6. Clear the cache and verify the project imported successfully.

Create a new, empty Magento Enterprise Edition project

If you do not have a provisioned project created and available, you need to create your project selecting the

  1. Access your account. You can open the email you received from Magento Cloud ( and click the Access your project now link. Or you can log in to your Magento Commerce account.
  2. Click the This project has no code yet link next to the Project name.

    Project without code

  3. Enter a name for the project.

    Project name

  4. Click Create a blank site from a template and click Continue. We recommend starting with the Magento template as your initial project option. If you have an existing Magento deployment, you can later import code, extensions, themes, and data after fully deploying this base Magento code.

    Create a site using the sample Magento project

  5. When prompted, enter your Magento Commerce Magento authentication keys in the provided fields. You created these keys earlier in the Magento Marketplace. Enter the private and public keys and click Finish.

    Enter your authentication keys

    The keys are added to the auth.json file in the repository master branch, required for all created branches and deployments.

  6. Wait a few minutes while the project deploys. A status of Pending displays until completed, similar to the following:

    Your sample Magento project

  7. After the project deploys, Success displays next to the name of your project.

Next step

Prepare your existing Magento Commerce install