How to get country collection in magento2
To get country collection in toOptionArray, you need to add following code in your file: First you need to inject a \Magento\Directory\Model\ResourceModel\Country\CollectionFactory in your class constructor: protected $_countryFactory; public function __construct( \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryFactory ) { $this->_countryFactory= $countryFactory; } Then in your class you can do: public function getAllOptions() { return $options = $this->getCountryCollection()->toOptionArray(); } public […]