Assign customer to company Magento 2 B2B.

You can add Customer to Company Programmatically by assignCustomer( ) function from CompanyManagementInterface.

Magento\Company\Api\CompanyManagementInterface Interface will be used for assign customer to Company in Magento 2.

You need Company id and Customer id to achieve this.

You can get assigned a company to customer programmatically by below way,


One Reply to “Assign customer to company Magento 2 B2B.”

  1. Hello, unfortunatelly, the assignCustomer method hasn’t worked for me. Could it be because I created the customer through the customer factory and then used its Id to assign it to an existing company? In my case, the customer gets created as an individual user but doesn’t get assigned to the company I specified through the assignCustomer method. Do you have any suggestions how to undertake this problem?

Leave a Reply