Get Company details by company id in Magento 2 B2B.

Magento 2 You can get company details by company id. if you have Company id and you want to fetch details of a company in B2B Magento you need to instantiate a
Magento\Company\Api\CompanyRepositoryInterface Interface in construct( ) method of your PHP file.

You can get all Company Collection by Get all Company Collection in B2B Magento 2

You can get Company Collection programmatically by below way,

<?php
class YourClass {
    public function __construct(
        \Magento\Company\Api\CompanyRepositoryInterface $companyRepository
    ) {
        $this->companyRepository = $companyRepository;
    }

    /**
    * @param int $companyId 
    **/
    public function getCompanyById($companyId)
    {
        try {
            $company = $this->companyRepository->get($companyId);
        } catch (NoSuchEntityException $e) {
            $company = null;
        }
        return $company;
    }
}

Get Details of company information from template file by below way, you need to pass company id as parameter.

$companyId = 3; //COMPANY_ID
$getCompany = $this->getCompanyById($companyId);
foreach($getCompany as $company) {
    echo $company->getCompanyName();echo "<br>";
    echo $company->getLegalName();echo "<br>";
    echo $company->getCompanyEmail();echo "<br>";
    echo $company->getCity();echo "<br>";
    echo $company->getTelephone();echo "<br>";
}