Get Customer Company extension attributes B2B magento 2.

In B2B, Magento 2 You can fetch a list of customer company extension attributes by customer ID.

The company module contains customer extension attributes that are mapped to the Customer module in the Magento core code.

List of Customer company extension attributes,

        • company_id
        • job_title
        • status
        • telephone

Check the Magento code to get customer company extension attributes,

namespace Package\Modulename\Model;

use Magento\Framework\Exception\LocalizedException;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Company\Api\Data\CompanyCustomerInterface;
use Magento\Framework\Exception\NoSuchEntityException;

class CompanyExtensionAttribute
    private CompanyCustomerInterface $customerAttributes;

    public function __construct(
        private CustomerRepositoryInterface $customerRepository
    ) {

     * Get customer extension attributes
     * @return CompanyCustomerInterface|null
     * @throws NoSuchEntityException
     * @throws LocalizedException
    public function getCustomerAttributes()
        $customerId = 10; // pass customer id
        if ($customerId && !$this->customerAttributes) {
            $this->customerAttributes = $this->customerRepository->getById($customerId)
        return $this->customerAttributes;

Now you can fetch any customer company extension attribute using the below code,

$jobTitle = '';
if ($this->getCustomerAttributes()) {
    $jobTitle = $this->getCustomerAttributes()->getJobTitle();

You can fetch telephone, status, and company ID using the above way.