Skip to content

Commit bb3d062

Browse files
committed
MAGETWO-56937: [Backport] - [GitHub] Setting SKU mask as empty crashes product Javascript in backend #5618 - for 2.1
1 parent 75a7b9b commit bb3d062

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/components/import-handler.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66
define([
7+
'underscore',
78
'Magento_Ui/js/form/element/textarea'
8-
], function (Textarea) {
9+
], function (_, Textarea) {
910
'use strict';
1011

1112
return Textarea.extend({
@@ -123,24 +124,21 @@ define([
123124
* Update field value, if it's allowed
124125
*/
125126
updateValue: function () {
126-
var str = this.mask,
127+
var str = this.mask || '',
127128
nonEmptyValueFlag = false,
128-
placeholder,
129-
property,
130129
tmpElement;
131130

132131
if (!this.allowImport) {
133132
return;
134133
}
135134

136-
for (property in this.values) {
137-
if (this.values.hasOwnProperty(property)) {
138-
placeholder = '';
139-
placeholder = placeholder.concat('{{', property, '}}');
140-
str = str.replace(placeholder, this.values[property]);
141-
nonEmptyValueFlag = nonEmptyValueFlag || !!this.values[property];
142-
}
135+
if (str) {
136+
_.each(this.values, function (propertyValue, propertyName) {
137+
str = str.replace('{{' + propertyName + '}}', propertyValue);
138+
nonEmptyValueFlag = nonEmptyValueFlag || !!propertyValue;
139+
});
143140
}
141+
144142
// strip tags
145143
tmpElement = document.createElement('div');
146144
tmpElement.innerHTML = str;

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,16 @@
2323
<item name="value" xsi:type="number">0</item>
2424
</field>
2525
</dataset>
26+
<dataset name="empty_product_mask_sku">
27+
<field name="catalog/fields_masks/sku" xsi:type="array">
28+
<item name="value" xsi:type="string"/>
29+
</field>
30+
</dataset>
31+
<dataset name="empty_product_mask_sku_rollback">
32+
<field name="catalog/fields_masks/sku" xsi:type="array">
33+
<item name="value" xsi:type="string">{{name}}</item>
34+
<item name="inherit" xsi:type="number">1</item>
35+
</field>
36+
</dataset>
2637
</repository>
2738
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,22 @@
449449
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
450450
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
451451
</variation>
452+
<variation name="CreateSimpleProductEntityWithEmptySkuMaskTest1" summary="Create Simple Product Entity With Empty Sku Mask" ticketId="MAGETWO-63556">
453+
<data name="configData" xsi:type="string">empty_product_mask_sku</data>
454+
<data name="description" xsi:type="string">Create product with custom options(fixed price)</data>
455+
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
456+
<data name="product/data/name" xsi:type="string">Simple Product %isolation%</data>
457+
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
458+
<data name="product/data/price/value" xsi:type="string">10000</data>
459+
<data name="product/data/weight" xsi:type="string">50</data>
460+
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">657</data>
461+
<data name="product/data/checkout_data/dataset" xsi:type="string">simple_drop_down_with_one_option_fixed_price</data>
462+
<data name="product/data/price/dataset" xsi:type="string">drop_down_with_one_option_fixed_price</data>
463+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
464+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" />
465+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
466+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" />
467+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCart" />
468+
</variation>
452469
</testCase>
453470
</config>

0 commit comments

Comments
 (0)