In this post I am going to explain how to get country collection in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_countryCollectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, array $data = [] ) { $this->_countryCollectionFactory = $countryCollectionFactory; parent::__construct($context, $data); } public function getCountryCollection() { $collection = $this->_countryCollectionFactory->create()->loadByStore();…
Recent Comments