Skip to content

Commit 13927e3

Browse files
committed
MAGETWO-91570: [2.2.x] - [Github]Can not save attribute #5907
- fixed default attribute setting
1 parent aa9f0f0 commit 13927e3

File tree

3 files changed

+14
-3
lines changed
  • app/code/Magento
    • Catalog
    • Swatches/Controller/Adminhtml/Product/Attribute/Plugin

3 files changed

+14
-3
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private function preprocessOptionsData(&$data)
331331
foreach ($serializedOptions as $serializedOption) {
332332
$option = [];
333333
parse_str($serializedOption, $option);
334-
$data = array_merge_recursive($data, $option);
334+
$data = array_replace_recursive($data, $option);
335335
}
336336
}
337337
unset($data['serialized_options']);

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,16 @@ define([
183183
editForm.on('submit', function () {
184184
optionPanel.find('input')
185185
.each(function () {
186-
optionsValues.push(this.name + '=' + jQuery(this).val());
186+
if (this.disabled) {
187+
return;
188+
}
189+
if (this.type == 'checkbox' || this.type == 'radio') {
190+
if (this.checked) {
191+
optionsValues.push(this.name + '=' + jQuery(this).val());
192+
}
193+
} else {
194+
optionsValues.push(this.name + '=' + jQuery(this).val());
195+
}
187196
});
188197
jQuery('<input>')
189198
.attr({

app/code/Magento/Swatches/Controller/Adminhtml/Product/Attribute/Plugin/Save.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public function beforeDispatch(Attribute\Save $subject, RequestInterface $reques
2626
$data = $request->getPostValue();
2727
//Data is serialized to overcome issues caused by max_input_vars value if it's modification is unavailable.
2828
//See subject controller code and comments for more info.
29-
if (isset($data['serialized_swatch_values'])) {
29+
if (isset($data['serialized_swatch_values'])
30+
&& in_array($data['frontend_input'], ['swatch_visual', 'swatch_text'])
31+
) {
3032
$data['serialized_options'] = $data['serialized_swatch_values'];
3133
}
3234
unset($data['serialized_swatch_values']);

0 commit comments

Comments
 (0)