You can get Company Collection in Magento 2 By
Magento\Company\Api\CompanyRepositoryInterface Interface.
CompanyRepositoryInterface contains useful function like Get, Save, Delete and GetList and DeleteById.
You can get List of Company Collection in B2B Magento by below way,
public function __construct(
\Magento\Company\Api\CompanyRepositoryInterface $companyRepository,
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->companyRepository = $companyRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
public function getCompanyList()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$companyList = $this->companyRepository->getList($searchCriteria)->getItems();
return $companyList;
}
Now Iterate the loop and Get Company Details,
$getCompany = $this->getCompanyList();
foreach($getCompany as $company) {
echo $company->getCompanyName(); echo $company->getLegalName();
}
Check More details for Company Collection, https://www.rakeshjesadiya.com/get-company-collection-in-magento-2-b2b/
... View more