Company Module in B2B Magento 2 allowed to create a registration for the company user from the storefront in Magneto 2.
Its store configuration setting to enable or disable storefront registration. By default, the B2B module allowed to create a registration from the frontend.
Go To admin panel,
Stores -> Configuration -> Company Configuration -> Allow Company Registration from the Storefront -> Yes/No.
You can check it also using the programmatic way with the use of StatusServiceInterface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php namespace Jesadiya\CompanyRegistration\Model; use Magento\Company\Api\StatusServiceInterface; class CompanyRegistrationEnable { /** * @var StatusServiceInterface */ private $companyRegistrationAllowed; public function __construct( StatusServiceInterface $companyRegistrationAllowed ) { $this->companyRegistrationAllowed = $companyRegistrationAllowed; } /** * Company registration allowed from the store front. * * @return bool */ public function isFrontRegistrationAllowed(): ?bool { $isStorefrontRegistrationAllowed = $this->companyRegistrationAllowed->isStorefrontRegistrationAllowed(); return $isStorefrontRegistrationAllowed; } } |
Call method to identify status,
echo $isCompanyActive = $this->isCompanyModuleActive();
If Output is 1, Company module is enable to work with B2B in Magento 2.
Output:
Boolean