Get Company Data by company id in B2B Magento 2.

You can get company data by company id in the B2B version of Magento Commerce or Magento Cloud Edition.

Get company data using B2B, You must install B2B extension first to get data of a company,

<?php
use Magento\Company\Api\CompanyRepositoryInterface;

class Company
{

    public function __construct(
        CompanyRepositoryInterface $companyRepository
    ) {
        $this->companyRepository = $companyRepository;
    }

    public function getCompanyData()
    {
	$company = null;
        $companyId = 3;
        try {
            $company = $this->companyRepository->get($companyId);
        } catch (\Exception $e) {
            throw new Exception("Error Processing Request", $e->getMessage());
        }
        return $company;
    }
}

Output:

Array
(
    [entity_id] => 3
    [status] => 1
    [company_name] => ztech
    [legal_name] => Rbj
    [company_email] => rakesh@example.com
    [street] => 200 E. 6th Street
    [city] => Austin
    [country_id] => US
    [region_id] => 57
    [postcode] => 78701
    [telephone] => 1234554321
    [customer_group_id] => 1
    [sales_representative_id] => 1
    [super_user_id] => 31
)

 

Customer reset password Error, We received too many requests for password resets. Please wait and try again later Magento 2.

When you forgot your password for the Magento customer account and try to reset your password, Many times you can see the error message like,

“We received too many requests for password resets. Please wait and try again later or contact hello@example.com.”

Continue reading “Customer reset password Error, We received too many requests for password resets. Please wait and try again later Magento 2.”

Get Current store locale/language programmatically in Magento 2.

Magento 2 with multi-store functionality, Different store view contains different locale.

You can set Different locale from admin panel using Stores -> Configuration -> General Tab.
Click on Locale Options, Continue reading “Get Current store locale/language programmatically in Magento 2.”