Skip to main content

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $allowerdContries = $objectManager->get('Magento\Directory\Model\AllowedCountries')->getAllowedCountries() ; $countryFactory = $objectManager->get('\Magento\Directory\Model\CountryFactory'); //echo "

"; print_r($allowerdContries);

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $allowerdContries = $objectManager->get('Magento\Directory\Model\AllowedCountries')->getAllowedCountries() ; $countryFactory = $objectManager->get('\Magento\Directory\Model\CountryFactory'); //echo "<pre>"; print_r($allowerdContries); $countries = array(); foreach($allowerdContries as $countryCode) { if($countryCode) { $data = $countryFactory->create()->loadByCode($countryCode); $countries[$countryCode] = $data->getName(); } }

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $allowerdContries = $objectManager->get('Magento\Directory\Model\AllowedCountries')->getAllowedCountries() ; $countryFactory = $objectManager->get('\Magento\Directory\Model\CountryFactory'); //echo "

"; print_r($allowerdContries);

$countries = array(); foreach($allowerdContries as $countryCode) { if($countryCode) { $data = $countryFactory->create()->loadByCode($countryCode); $countries[$countryCode] = $data->getName(); } }
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
            $allowerdContries = $objectManager->get('Magento\Directory\Model\AllowedCountries')->getAllowedCountries() ;
            $countryFactory = $objectManager->get('\Magento\Directory\Model\CountryFactory');
            //echo "<pre>"; print_r($allowerdContries);

            $countries = array();
            foreach($allowerdContries as $countryCode)
            {
                    if($countryCode)
                    {

                        $data = $countryFactory->create()->loadByCode($countryCode);
                        $countries[$countryCode] =  $data->getName();
                    }
            }
Source Link

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $allowerdContries = $objectManager->get('Magento\Directory\Model\AllowedCountries')->getAllowedCountries() ; $countryFactory = $objectManager->get('\Magento\Directory\Model\CountryFactory'); //echo "

"; print_r($allowerdContries);

$countries = array(); foreach($allowerdContries as $countryCode) { if($countryCode) { $data = $countryFactory->create()->loadByCode($countryCode); $countries[$countryCode] = $data->getName(); } }