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,