Skip to content

Commit 59f9e53

Browse files
author
Michail Slabko
committed
MAGETWO-44055: [GITHUB] Admin product «Custom Options» tab controls («Import Options», «Add New Option» buttons) do not work when non-English locale is used #1971
1 parent 8c692e6 commit 59f9e53

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function toOptionArray()
4343
$types[] = ['label' => __($type['label']), 'value' => $type['name']];
4444
}
4545
if (count($types)) {
46-
$groups[] = ['label' => __($option['label']), 'value' => $types];
46+
$groups[] = ['label' => __($option['label']), 'value' => $types, 'optgroup-name' => $option['label']];
4747
}
4848
}
4949

app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ define([
194194
var widget = this,
195195
currentElement = $(event.target),
196196
parentId = '#' + currentElement.closest('.fieldset-alt').attr('id'),
197-
group = currentElement.find('[value="' + currentElement.val() + '"]').closest('optgroup').attr('data-name'),
197+
group = currentElement.find('[value="' + currentElement.val() + '"]')
198+
.closest('optgroup').attr('data-optgroup-name'),
198199
previousGroup = $(parentId + '_previous_group').val(),
199200
previousBlock = $(parentId + '_type_' + previousGroup),
200201
tmpl;

lib/internal/Magento/Framework/View/Element/Html/Select.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,21 @@ protected function _toHtml()
151151

152152
$isArrayOption = true;
153153
foreach ($this->getOptions() as $key => $option) {
154+
$optgroupName = '';
154155
if ($isArrayOption && is_array($option)) {
155156
$value = $option['value'];
156157
$label = (string)$option['label'];
157-
$name = $option['label'] instanceof \Magento\Framework\Phrase ? $option['label']->getText() : $label;
158+
$optgroupName = isset($option['optgroup-name']) ? $option['optgroup-name'] : $label;
158159
$params = !empty($option['params']) ? $option['params'] : [];
159160
} else {
160161
$value = (string)$key;
161162
$label = (string)$option;
162-
$name = $label;
163163
$isArrayOption = false;
164164
$params = [];
165165
}
166166

167167
if (is_array($value)) {
168-
$html .= '<optgroup label="' . $label . '" data-name="' . $name . '">';
168+
$html .= '<optgroup label="' . $label . '" data-optgroup-name="' . $optgroupName . '">';
169169
foreach ($value as $keyGroup => $optionGroup) {
170170
if (!is_array($optionGroup)) {
171171
$optionGroup = ['value' => $keyGroup, 'label' => $optionGroup];

0 commit comments

Comments
 (0)