Magento2 – How to Get Country Name Using Country Code

Create Instance to Object Manager then inject dependency to perform your query: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); Now load your country by the following code: $country = $objectManager->create(‘\Magento\Directory\Model\Country’)->load(‘AE’)->getName(); While AE is the country code. The output of above code will be: United Arab Emirates

Magento2 How to Get Country Code Collection

Fortunately magento2 introduces many ways to get data from collection. Here we are following from those of two approaches : 1. Get the country code collection by getting the instance of object manager class and get the method by passing class dependency to ‘get’ method of objectManager class instance: $o = \Magento\Framework\App\ObjectManager::getInstance(); $_countryCollectionFactory = $o->get(‘\Magento\Directory\Model\ResourceModel\Country\CollectionFactory’); …