directoryHelper = $directoryHelper; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; } /** * Substitute empty value with Default country. * * @return void */ protected function _afterLoad() { $value = (string)$this->getValue(); if (empty($value)) { if ($this->getWebsite()) { $defaultCountry = $this->_storeManager->getWebsite( $this->getWebsite() )->getConfig( \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_COUNTRY ); } else { $defaultCountry = $this->directoryHelper->getDefaultCountry($this->getStore()); } $this->setValue($defaultCountry); } } }