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:
1
magento-cloud login
-
List your projects. With the project ID, you can complete additional commands.
1
magento-cloud project:list
-
If necessary, clone the project to your local. You should have cloned when setting up your local development workspace.
1
magento-cloud project:get <project ID>
- Change to a project directory. For example,
cd /var/www/html/magento2
-
List environments in the project. Every environment includes an active Git branch of your code, database, environment variables, configurations, and services.
1
magento-cloud environment:list
magento-cloud environment:list
—displays environment hierarchies whereas thegit branch
command does not. -
Fetch origin branches to get the latest code:
1
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.
1
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):
1
git pull origin <environment ID>
-
Create a snapshot of the environment as a backup:
1
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.
1
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:
1
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
composer.json
andcomposer.lock
files.1
git add composer.json composer.lock && git commit -a -m "install b2b module"
-
Enable all missing modules, including B2B, for updating.
1
./vendor/bin/ece-tools module:refresh
-
Complete the upgrade with B2B using the following command:
1
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.
1
git add -f app/etc/config.php
1
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.