Set up Magento B2B

With the Magento Commerce Cloud Pro subscription for v2.2 and later, you can install and setup Magento Business to Business (B2B) Commerce features. B2B supports merchants whose customers are other companies. This section provides specific information for installing and setting up B2B in Magento Commerce Cloud.

For additional information on using and extending B2B, see the following guides:

We provide these features as a module you can install and setup in Magento Commerce Cloud. Installation of B2B in a Pro project require additional steps to add the module and update your Git branch.

Prerequisites for adding B2B

Prior to adding the B2B module, you should have the following:

  • Upgraded to a Magento Commerce Cloud 2.2.X on your environments
  • A Git branch to add the new B2B module
  • Have your Magento Authentication keys (public and private) available

We provide B2B as a module for Magento. For new Pro projects, we highly recommend having Magento Commerce Cloud fully deployed to Integration, Staging, and Production environments. For more information, see First time deployment. Adding a module as part of your initial deployment could cause issues.

Create a branch to work in

We recommend working in a branch to add the B2B module and features to your implementation. If you have a branch, continue to Add B2B in the cloud.

  1. Log in to your local development system, or switch to, the Magento file system owner.
  2. Change to a directory to which the Magento file system owner has write access.
  3. Enter the following command in a terminal to log in to your project:

     magento-cloud login
  4. List your projects. With the project ID, you can complete additional commands.

     magento-cloud project:list
  5. If necessary, clone the project to your local. You should have cloned when setting up your local development workspace.

     magento-cloud project:get <project ID>
  6. Change to a project directory. For example, cd /var/www/html/magento2
  7. List environments in the project. Every environment includes an active Git branch of your code, database, environment variables, configurations, and services.

     magento-cloud environment:list

    magento-cloud environment:list—displays environment hierarchies whereas the git branch command does not.

  8. Fetch origin branches to get the latest code:

     git fetch origin
  9. Check out, or switch to, a specific branch and environment. Git commands only checkout the Git branch. The Magento Cloud command also switches to the active environment.

     magento-cloud environment:checkout <environment ID>

    To create a new environment, use magento-cloud environment:branch <environment name> <parent environment ID>

  10. Pull any updated code to your local for the environment ID (which is the Git branch):

     git pull origin <environment ID>
  11. Create a snapshot of the environment as a backup:

     magento-cloud snapshot:create -e <environment ID>

Add B2B in the cloud

You need to add the module to composer.json. All extensions and modules must be added to this file. These instructions are specific to Magento Commerce Cloud. For more information, you can also review the installation instructions in the B2B guide.

  1. Open a terminal application.
  2. Change to your local development environment root directory.
  3. Install the B2B module using composer.

    composer require magento/extension-b2b

    You may be prompted to enter your Magento Authentication keys (public and private). If copying and pasting your keys, do not introduce additional spaces. Spaces could cause the following error:

    InvalidArgumentException - Could not find package magento/extension-b2b at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability.
  4. Add and commit the updated composer.json and composer.lock files.

    git add composer.json composer.lock && git commit -a -m "install b2b module"
  5. Enable all missing modules, including B2B, for updating.

    ./vendor/bin/ece-tools module:refresh
  6. Complete the upgrade with B2B using the following command:

    php bin/magento setup:upgrade

If you have a config.php file as part of your deployment, you should also add the B2B module in the modules section of the file.

  1. Change to the app/etc directory.
  2. Edit the config.php with a text editor.
  3. In the modules list, add the B2B module.
  4. Save the file and update Git.

    git add -f app/etc/config.php
    git commit -a -m “Add config.php.”

Configure and use B2B

For additional information on using and configuring B2B, review the Magento B2B User Guide. To extend functionality, see the Magento B2B Developer Guide.