Skip to content

Commit 717a56c

Browse files
committed
MAGETWO-72001: 'Asymmetric transaction rollback' error after saving product with FPT attribute
1 parent 4381a6b commit 717a56c

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/components/disable-on-option/yesno.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,37 @@ define([
88
], function (Element, strategy) {
99
'use strict';
1010

11-
return Element.extend(strategy);
11+
var comp = Element.extend(strategy).extend({
12+
13+
defaults: {
14+
listens: {
15+
disabled: 'updateValueForDisabledField',
16+
visible: 'updateValueForDisabledField'
17+
}
18+
},
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
initialize: function () {
24+
this._super();
25+
this.updateValueForDisabledField();
26+
27+
return this;
28+
},
29+
30+
/**
31+
* Set element value to O(No) if element is invisible and disabled
32+
* Set element value to initialValue if element becomes visible and enable
33+
*/
34+
updateValueForDisabledField: function () {
35+
if (!this.disabled() && this.visible()) {
36+
this.set('value', this.initialValue);
37+
} else {
38+
this.set('value', 0);
39+
}
40+
}
41+
});
42+
43+
return comp.extend(strategy);
1244
});

app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
<notice translate="true">Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice>
4949
<label translate="true">Use in Search Results Layered Navigation</label>
5050
<dataScope>is_filterable_in_search</dataScope>
51+
<imports>
52+
<link name="visible">${ $.parentName}:visible</link>
53+
</imports>
5154
</settings>
5255
<formElements>
5356
<checkbox>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define(['Magento_Catalog/js/components/disable-on-option/yesno'], function (YesNo) {
7+
'use strict';
8+
9+
var model;
10+
11+
describe('Magento_Catalog/js/components/disable-on-option/yesno', function () {
12+
beforeEach(function () {
13+
model = new YesNo({
14+
name: 'dynamic_rows',
15+
dataScope: '',
16+
value: 12,
17+
visible: true,
18+
disabled: false
19+
20+
});
21+
});
22+
23+
it('Verify initial value', function () {
24+
expect(model.get('value')).toBe(12);
25+
});
26+
it('Verify value when element becomes invisible', function () {
27+
model.set('visible', false);
28+
expect(model.get('value')).toBe(0);
29+
});
30+
it('Verify value when element becomes disabled', function () {
31+
model.set('disabled', false);
32+
expect(model.get('value')).toBe(12);
33+
});
34+
it('Verify value when element becomes invisable and disabled', function () {
35+
model.set('disabled', true);
36+
model.set('visible', false);
37+
expect(model.get('value')).toBe(0);
38+
});
39+
});
40+
});

0 commit comments

Comments
 (0)