Skip to content

Commit 43ad113

Browse files
committed
MAGETWO-34253: CLONE - Postal code is still mandatory for Non-US addresses that don't use it
- Fix data-source with 'is_region_required' value
1 parent 91b710e commit 43ad113

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

app/code/Magento/Directory/Model/Resource/Country/Collection.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
4444
*/
4545
protected $_localeResolver;
4646

47+
/**
48+
* @var \Magento\Directory\Helper\Data
49+
*/
50+
protected $helperData;
51+
4752
/**
4853
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
4954
* @param \Psr\Log\LoggerInterface $logger
@@ -68,6 +73,7 @@ public function __construct(
6873
\Magento\Directory\Model\Resource\CountryFactory $countryFactory,
6974
\Magento\Framework\Stdlib\ArrayUtils $arrayUtils,
7075
\Magento\Framework\Locale\ResolverInterface $localeResolver,
76+
\Magento\Framework\App\Helper\AbstractHelper $helperData,
7177
$connection = null,
7278
\Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
7379
) {
@@ -77,6 +83,7 @@ public function __construct(
7783
$this->_localeResolver = $localeResolver;
7884
$this->_countryFactory = $countryFactory;
7985
$this->_arrayUtils = $arrayUtils;
86+
$this->helperData = $helperData;
8087
}
8188

8289
/**
@@ -208,7 +215,11 @@ public function toOptionArray($emptyLabel = ' ')
208215
}
209216
$options = [];
210217
foreach ($sort as $label => $value) {
211-
$options[] = ['value' => $value, 'label' => $label];
218+
$option = ['value' => $value, 'label' => $label];
219+
if ($this->helperData->isRegionRequired($value)) {
220+
$option['is_region_required'] = 'true';
221+
}
222+
$options[] = $option;
212223
}
213224

214225
if (count($options) > 0 && $emptyLabel !== false) {

app/code/Magento/Directory/etc/di.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9-
<type name="Magento\Directory\Model\Resource\Country\Collection" shared="false" />
109
<type name="Magento\Directory\Model\Currency\Import\Config">
1110
<arguments>
1211
<argument name="servicesConfig" xsi:type="array">
@@ -17,4 +16,15 @@
1716
</argument>
1817
</arguments>
1918
</type>
19+
20+
<virtualType name="DirectoryHelperDataProxy" type="Magento\Directory\Helper\Data\Proxy">
21+
<arguments>
22+
<argument name="instanceName" xsi:type="string">Magento\Directory\Helper\Data</argument>
23+
</arguments>
24+
</virtualType>
25+
<type name="Magento\Directory\Model\Resource\Country\Collection" shared="false">
26+
<arguments>
27+
<argument name="helperData" xsi:type="object">DirectoryHelperDataProxy</argument>
28+
</arguments>
29+
</type>
2030
</config>

0 commit comments

Comments
 (0)