Skip to content

Commit 1e17b1e

Browse files
committed
ACP2E-1881: Inventory source removed when update configurable product when MSI enable
1 parent 2ad6b01 commit 1e17b1e

File tree

2 files changed

+88
-13
lines changed
  • app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps
  • dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/adminhtml/js/variations/steps

2 files changed

+88
-13
lines changed

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,8 @@ define([
135135
if (productId && !images.file) {
136136
images = product.images;
137137
}
138-
productDataFromGrid = _.pick(
139-
productDataFromGrid,
140-
'sku',
141-
'name',
142-
'weight',
143-
'status',
144-
'price',
145-
'qty'
146-
);
138+
productDataFromGrid = this.prepareProductDataFromGrid(productDataFromGrid);
147139

148-
if (productDataFromGrid.hasOwnProperty('qty')) {
149-
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
150-
}
151-
delete productDataFromGrid.qty;
152140
product = _.pick(
153141
product || {},
154142
'sku',
@@ -288,6 +276,32 @@ define([
288276
* Back.
289277
*/
290278
back: function () {
279+
},
280+
281+
/**
282+
* Prepare product data from grid to have all the current fields values
283+
*
284+
* @param {Object} productDataFromGrid
285+
* @return {Object}
286+
*/
287+
prepareProductDataFromGrid: function (productDataFromGrid) {
288+
productDataFromGrid = _.pick(
289+
productDataFromGrid,
290+
'sku',
291+
'name',
292+
'weight',
293+
'status',
294+
'price',
295+
'qty'
296+
);
297+
298+
if (productDataFromGrid.hasOwnProperty('qty')) {
299+
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
300+
}
301+
302+
delete productDataFromGrid.qty;
303+
304+
return productDataFromGrid;
291305
}
292306
});
293307
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
7+
/* eslint max-nested-callbacks: 0 */
8+
/* jscs:disable jsDoc*/
9+
10+
define([
11+
'Magento_ConfigurableProduct/js/variations/steps/summary'
12+
], function (Summary) {
13+
'use strict';
14+
15+
describe('Magento_ConfigurableProduct/js/variations/steps/summary', function () {
16+
let model, quantityFieldName, productDataFromGrid, productDataFromGridExpected;
17+
18+
beforeEach(function () {
19+
quantityFieldName = 'quantity123';
20+
model = new Summary({quantityFieldName: quantityFieldName});
21+
22+
productDataFromGrid = {
23+
sku: 'testSku',
24+
name: 'test name',
25+
weight: 12.12312,
26+
status: 1,
27+
price: 333.333,
28+
someField: 'someValue',
29+
quantity: 10
30+
};
31+
32+
productDataFromGrid[quantityFieldName] = 12;
33+
34+
productDataFromGridExpected = {
35+
sku: 'testSku',
36+
name: 'test name',
37+
weight: 12.12312,
38+
status: 1,
39+
price: 333.333
40+
};
41+
});
42+
43+
describe('Check prepareProductDataFromGrid', function () {
44+
45+
it('Check call to prepareProductDataFromGrid method with qty', function () {
46+
productDataFromGrid.qty = 3;
47+
productDataFromGridExpected[quantityFieldName] = 3;
48+
const result = model.prepareProductDataFromGrid(productDataFromGrid);
49+
50+
expect(result).toEqual(productDataFromGridExpected);
51+
});
52+
53+
54+
it('Check call to prepareProductDataFromGrid method without qty', function () {
55+
const result = model.prepareProductDataFromGrid(productDataFromGrid);
56+
57+
expect(result).toEqual(productDataFromGridExpected);
58+
});
59+
});
60+
});
61+
});

0 commit comments

Comments
 (0)