Skip to content

Commit b0e3089

Browse files
MAGETWO-99424: "0" in country dropdown list when allowed countries differs from top destinations
1 parent 84848b5 commit b0e3089

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,6 @@ public function __construct(
126126
*/
127127
protected $_foregroundCountries = [];
128128

129-
/**
130-
* Add top destinition countries to head of option array
131-
*
132-
* @param string $emptyLabel
133-
* @param array $options
134-
* @return array
135-
*/
136-
private function addForegroundCountriesToOptionArray($emptyLabel, $options)
137-
{
138-
if ($emptyLabel !== false && count($this->_foregroundCountries) !== 0 &&
139-
count($options) === count($this->_foregroundCountries)
140-
) {
141-
$options[] = ['value' => '', 'label' => $emptyLabel];
142-
return $options;
143-
}
144-
return $options;
145-
}
146-
147129
/**
148130
* Define main table
149131
*
@@ -283,7 +265,6 @@ public function toOptionArray($emptyLabel = ' ')
283265

284266
$options = [];
285267
foreach ($sort as $label => $value) {
286-
$options = $this->addForegroundCountriesToOptionArray($emptyLabel, $options);
287268
$option = ['value' => $value, 'label' => $label];
288269
if ($this->helperData->isRegionRequired($value)) {
289270
$option['is_region_required'] = true;

app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Country/CollectionTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public function testToOptionArray($optionsArray, $emptyLabel, $foregroundCountri
9999

100100
$this->_model->setForegroundCountries($foregroundCountries);
101101
$result = $this->_model->toOptionArray($emptyLabel);
102-
$this->assertCount(count($optionsArray) + (int)(!empty($emptyLabel) && !empty($foregroundCountries)) +
103-
(int)(!empty($emptyLabel)), $result);
102+
$this->assertCount(count($optionsArray) + (int)(!empty($emptyLabel)), $result);
104103
foreach ($expectedResults as $index => $expectedResult) {
105104
$this->assertEquals($expectedResult, $result[$index]['label']);
106105
}
@@ -121,10 +120,10 @@ public function toOptionArrayDataProvider()
121120
[$optionsArray, false, [], ['AD', 'US', 'ES', 'BZ']],
122121
[$optionsArray, false, 'US', ['US', 'AD', 'ES', 'BZ']],
123122
[$optionsArray, false, ['US', 'BZ'], ['US', 'BZ', 'AD', 'ES']],
124-
[$optionsArray, ' ', 'US', [' ', 'US', ' ', 'AD', 'ES', 'BZ']],
123+
[$optionsArray, ' ', 'US', [' ', 'US', 'AD', 'ES', 'BZ']],
125124
[$optionsArray, ' ', [], [' ', 'AD', 'US', 'ES', 'BZ']],
126-
[$optionsArray, ' ', 'UA', [' ', 'AD', ' ', 'US', 'ES', 'BZ']],
127-
[$optionsArray, ' ', ['AF', 'UA'], [' ', 'AD', 'US', ' ', 'ES', 'BZ']],
125+
[$optionsArray, ' ', 'UA', [' ', 'AD', 'US', 'ES', 'BZ']],
126+
[$optionsArray, ' ', ['AF', 'UA'], [' ', 'AD', 'US', 'ES', 'BZ']],
128127
];
129128
}
130129
}

0 commit comments

Comments
 (0)