55 \
Magento\Framework\Json\EncoderInterface $jsonEncoder,
56 \
Magento\Framework\
App\Cache\Type\Config $configCacheType,
61 parent::__construct($context,
$data);
63 $this->_jsonEncoder = $jsonEncoder;
64 $this->_configCacheType = $configCacheType;
65 $this->_regionCollectionFactory = $regionCollectionFactory;
66 $this->_countryCollectionFactory = $countryCollectionFactory;
74 return $this->
getUrl(
'directory/json/childRegion');
84 $collection = $this->_countryCollectionFactory->create()->loadByStore();
98 $destinations = (string)$this->_scopeConfig->getValue(
99 'general/country/destinations',
100 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
102 return !empty($destinations) ? explode(
',', $destinations) : [];
114 \Magento\Framework\Profiler::start(
'TEST: ' . __METHOD__, [
'group' =>
'TEST',
'method' => __METHOD__]);
115 if ($defValue ===
null) {
118 $cacheKey =
'DIRECTORY_COUNTRY_SELECT_STORE_' . $this->_storeManager->getStore()->getCode();
119 $cache = $this->_configCacheType->load($cacheKey);
126 $this->_configCacheType->save($this->getSerializer()->
serialize(
$options), $cacheKey);
129 \
Magento\Framework\View\Element\Html\Select::class
141 'data-validate="{\'validate-select\':true}"' 144 \Magento\Framework\Profiler::stop(
'TEST: ' . __METHOD__);
167 \Magento\Framework\Profiler::start(
'TEST: ' . __METHOD__, [
'group' =>
'TEST',
'method' => __METHOD__]);
168 $cacheKey =
'DIRECTORY_REGION_SELECT_STORE' . $this->_storeManager->getStore()->getId();
169 $cache = $this->_configCacheType->load($cacheKey);
174 $this->_configCacheType->save($this->getSerializer()->
serialize(
$options), $cacheKey);
177 \
Magento\Framework\View\Element\Html\Select::class
185 'required-entry validate-state' 187 intval($this->getRegionId())
191 \Magento\Framework\Profiler::start(
'TEST: ' . __METHOD__, [
'group' =>
'TEST',
'method' => __METHOD__]);
200 $countryId = $this->
getData(
'country_id');
201 if ($countryId ===
null) {
202 $countryId = $this->directoryHelper->getDefaultCountry();
212 \Magento\Framework\Profiler::start(
'TEST: ' . __METHOD__, [
'group' =>
'TEST',
'method' => __METHOD__]);
213 $regionsJs = $this->
getData(
'regions_js');
217 $countryIds[] = $country->getCountryId();
219 $collection = $this->_regionCollectionFactory->create()->addCountryFilter($countryIds)->load();
222 if (!$region->getRegionId()) {
225 $regions[$region->getCountryId()][$region->getRegionId()] = [
226 'code' => $region->getCode(),
227 'name' => $region->getName(),
230 $regionsJs = $this->_jsonEncoder->encode($regions);
232 \Magento\Framework\Profiler::stop(
'TEST: ' . __METHOD__);
242 private function getSerializer()
244 if ($this->serializer ===
null) {
246 ->get(\
Magento\Framework\Serialize\SerializerInterface::class);
248 return $this->serializer;
getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country')
getData($key='', $index=null)
$_regionCollectionFactory
serialize($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
$_countryCollectionFactory
getUrl($route='', $params=[])
setData($key, $value=null)
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, array $data=[])
if(!isset($_GET['name'])) $name