I need full country name using short code. I have code for magento 1.9 But I need it for magento2. can any one help me please.

$customerBillingCountry = 'IE'; 

$customerBillingCountry = Mage::app()->getLocale()->getCountryTranslation($customerBillingCountry);

Try This

$customerBillingCountry =   $objectManager->create('\Magento\Directory\Model\Country')->load($customerBillingCountry)->getName();

Use this code to get the full name of the country from country code

public function __construct(
        \Magento\Directory\Model\CountryFactory $countryFactory
        $this->_countryFactory = $countryFactory;

public function getCountryname($countryCode){    
    $country = $this->_countryFactory->create()->loadByCode($countryCode)
    return $country->getName();

call in your template file

echo $block->getCountryname($countryCode);
  • 1
    I have used it on outside of magento and this was worked perfect. $customerBillingCountry = $objectManager->create('\Magento\Directory\Model\Country')->load($customerBillingCountry)->getName(); – Pratik Kamani Sep 21 '18 at 13:03
  • 1
    Ok. it's another solution using block method. – Evince Development Sep 21 '18 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.