2021年3月3日星期三

How to get Magento 2 Country Collection

I hope you are doing well.

I want to get all the countries in the below format.

$countries = [    "AU" => "Australia",    "IN" => "India",    "US" => "United States",    "UK" => "United Kingdom",    .......  ]  

I tried but no use, i am always getting CountryId as 2 digit names like

$countries = [    0 => "AU",    1 => "IN",    2 => "US",    3 => "UK",    .......  ]  

I have used the following code

Magento\Directory\Model\ResourceModel\Country\Collection::loadByStore()  

How can i achieve this in Magento 2 ?

Thanks in advance.

https://stackoverflow.com/questions/66382417/how-to-get-magento-2-country-collection February 26, 2021 at 04:24PM

没有评论:

发表评论