Import existing code into a project

You can create a Adobe Commerce on cloud infrastructure project from a blank template or by importing existing code. We recommend starting with a blank template first, and then importing existing code on top of it.

Prerequisites for importing code

Before you begin, do the following:

SSH access to cloud environments

To transfer the database dump and files to Adobe Commerce on cloud infrastructure, you must know the SSH access link. You can locate the SSH access link using the Magento Cloud CLI tool:

1
magento-cloud environment:ssh --pipe

You must enter all Adobe Commerce on cloud infrastructure 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

You need your Adobe Commerce on cloud infrastructure database name and credentials so that you can import your Adobe Commerce data. You can find the name and credentials for your Adobe Commerce on cloud infrastructure database in the $MAGENTO_CLOUD_RELATIONSHIPS environment variable.

To find Adobe Commerce on cloud infrastructure database access information:

  1. Log in to your remote repository using SSH.

    1
    
    magento-cloud ssh -p <project-ID> -e <environment-ID>
    
  2. List all database information:

    1
    
    echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    database" : [
       {
          "username" : "user",
          "query" : {
             "is_master" : true
          },
          "path" : "main",
          "port" : 3306,
          "host" : "database.internal",
          "password" : "",
          "scheme" : "mysql",
          "ip" : "192.0.2.150"
       }
    ]
    

In the previous example, the database name is main, the listen port is 3306, the hostname is database.internal, the root username is user, and the user has no password.

Cloud unsecure base URL

After you import the Adobe Commerce database into Adobe Commerce on cloud infrastructure, you must change the base URL so you can access the Admin and storefront.

Use the magento-cloud CLI tool to locate the base URL:

1
magento-cloud 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, create a new project from a template. This new project has files and directories specific to Adobe Commerce on cloud infrastructure.
  2. Replace the contents of this project with your code using Git.
  3. Import your database into your Adobe Commerce on cloud infrastructure project.
  4. Import your static files into your Adobe Commerce on cloud infrastructure project.
  5. Copy your Adobe Commerce encryption key to your Adobe Commerce on cloud infrastructure project. This key is required for data migration and access.
  6. Clear the cache and verify the project imported successfully.

Create a new Adobe Commerce on cloud infrastructure project

  1. Access your account. Open the email you received from Adobe (accounts@magento.cloud) and click the Access your project now link. Or you can log in to your Adobe 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 Adobe Commerce template as your initial project option. If you have an existing Adobe Commerce deployment, you can import existing code later.

    Create a site using the sample project

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

    Enter your authentication keys

    The keys are added to the auth.json file and the file is required for all 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 project

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

Next step

Prepare your existing Adobe Commerce install