Magento Commerce only

Install B2B

The Magento Commerce for B2B extension is only available for Magento Commerce v2.2.0 or later. You must install it after installing Magento Commerce.

  1. Change to your Magento installation directory and enter the following command to update your composer.json file and install the Magento Commerce for B2B extension:

    1
    
     composer require magento/extension-b2b
    

    If you get an error when trying to install the B2B module for a local instance of Magento Commerce for example:

    1
    
     [InvalidArgumentException] Could not find a matching version of package magento/extension-b2b.
    

    Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).

    If not already denfined globally in your COMPOSER_HOME, you will need to create an auth.json file in the Magento root directory and add the following code, using the actual values of your public_key and private_key for username and password:

    1
    2
    3
    4
    5
    6
    7
    8
    
     {
        "http-basic": {
           "repo.magento.com": {
              "username": "<public_key>",
              "password": "<private_key>"
           }
        }
     }
    
  2. When prompted, enter your authentication keys. Your public key is your username; your private key is your password. If you have stored your public and private keys in auth.json, you won’t be asked to enter them here.

  3. Run the following commands after Composer finishes updating modules:

    1
    
     bin/magento setup:upgrade
    
    1
    
     bin/magento setup:di:compile
    
    1
    
     bin/magento setup:static-content:deploy -f
    
    1
    
     bin/magento cache:clean
    

Note: In Production mode, you may receive a message to ‘Please rerun Magento compile command’. Enter the commands above. Magento does not prompt you to run the compile command in Developer mode.

After completing the installation, you must follow the post-installation steps.

Configure

After installing the Magento Commerce for B2B extension, follow these instructions to launch Magento Commerce for B2B.

Start message consumers

The Magento Commerce for B2B extension uses MySQL for message queue management. If you want to enable the B2B Shared Catalog feature, you must start the corresponding message consumers after installation.

  1. List the available message consumers:

    1
    
     bin/magento queue:consumers:list
    

    You should see the following consumers:

    1
    2
    3
    4
    5
    
     sharedCatalogUpdatePrice
     sharedCatalogUpdateCategoryPermissions
     quoteItemCleaner
     inventoryQtyCounter
     async.operations.all
    
  2. Start each consumer separately:

    1
    
     bin/magento queue:consumers:start <consumer_name>
    

    For example:

    1
    
     bin/magento queue:consumers:start sharedCatalogUpdatePrice
    

Append & to the command to run it in the background, return to a prompt, and continue running commands. For example: bin/magento queue:consumers:start sharedCatalogUpdatePrice &.

Refer to Manage message queues for more information.

Add message consumers to cron

You may also add these two message consumers to the cron job (optional). For this, add these lines in your crontab:

1
2
* * * * * ps ax | grep [s]haredCatalogUpdateCategoryPermissions >>/dev/null 2>&1 || nohup php /var/www/html/magento2/bin/magento queue:consumers:start sharedCatalogUpdateCategoryPermissions &
* * * * * ps ax | grep [s]haredCatalogUpdatePrice >>/dev/null 2>&1 || nohup php /var/www/html/magento2/bin/magento queue:consumers:start sharedCatalogUpdatePrice &

Specify parameters for message consumers

Depending on your system configuration, to prevent possible issues, you may also need to specify the following parameters when starting the services:

  • --max-messages: manages the consumer’s lifetime and allows you to specify the maximum number of messages processed by the consumer. The best practice for a PHP application is to restart long-running processes to prevent possible memory leaks.

  • --batch-size: allows you to limit the system resources consumed by the consumers (CPU, memory). Using smaller batches reduces resource usage and, thus, leads to slower processing.

Enable B2B features in Magento Admin

After installing the Magento Commerce for B2B extension and starting message consumers (if you want to enable the Shared Catalog module), you must also enable B2B modules in Magento Admin.

If you enable the Shared Catalog module, you must also enable the Company module. The Quick Order and Requisition Lists modules can be enabled/disabled independently.

  1. Access the Magento Admin and click Stores > Settings > Configuration > General > B2B Features.

  2. Select Yes from the drop-down menus to enable B2B features:

    Enable B2B features

  3. Click Save Config.

Looking for more documentation? Checkout the B2B Developer Guide and User Guide.