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.
- Log in to your local development system, or switch to, the Magento file system owner.
- Change to a directory to which the Magento file system owner has write access.
Enter the following command in a terminal to log in to your project:
List your projects. With the project ID, you can complete additional commands.
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>
- Change to a project directory. For example,
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—displays environment hierarchies whereas the
git branchcommand does not.
Fetch origin branches to get the latest code:
git fetch origin
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>
Pull any updated code to your local for the environment ID (which is the Git branch):
git pull origin <environment ID>
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.
- Open a terminal application.
- Change to your local development environment root directory.
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.
Add and commit the updated
git add composer.json composer.lock && git commit -a -m "install b2b module"
Enable all missing modules, including B2B, for updating.
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.
- Change to the app/etc directory.
- Edit the config.php with a text editor.
- In the modules list, add the B2B module.
Save the file and update Git.
git add -f app/etc/config.php
git commit -a -m “Add config.php.”