Country\Collection
Magento\Directory\Model\ResourceModel\Country\Collection
What it does
This collection class manages and retrieves country data from the database in Magento 2.
Developers use it to load countries filtered by store configuration, country codes/IDs, convert countries to option arrays for dropdowns, and determine which countries require state/region selection.
It's commonly used in checkout, address forms, and anywhere country selection is needed.
Public Methods
- loadByStore()
- getItemById()
- addCountryCodeFilter()
- addCountryIdFilter()
- toOptionArray()
- setForegroundCountries()
- getCountriesWithRequiredStates()