Skip to content

Commit d685149

Browse files
committed
Merge remote-tracking branch 'goinc/MAGETWO-47700' into pr-539
# Conflicts: # app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js
2 parents f93b8da + ae94719 commit d685149

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,8 @@ protected function getButtonSet()
310310
'title' => __('Add Products Manually'),
311311
'sortOrder' => 10,
312312
'imports' => [
313-
'visible' => '!ns = ${ $.ns }, index = '
314-
. ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty',
315-
'disabled' => 'ns = ${ $.ns }, index = '
316-
. ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty',
313+
'visible' => 'ns = ${ $.ns }, index = '
314+
. ConfigurablePanel::CONFIGURABLE_MATRIX . ':isShowAddProductButton',
317315
],
318316
],
319317
],

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ define([
2424
insertDataFromWizard: [],
2525
map: null,
2626
isEmpty: true,
27+
isShowAddProductButton: false,
2728
cacheGridData: [],
2829
unionInsertData: [],
2930
deleteProperty: false,
3031
dataLength: 0,
3132
identificationProperty: 'id',
3233
'attribute_set_id': '',
34+
attributesTmp: [],
3335
listens: {
3436
'insertDataFromGrid': 'processingInsertDataFromGrid',
3537
'insertDataFromWizard': 'processingInsertDataFromWizard',
@@ -118,7 +120,9 @@ define([
118120
tmpArray.splice(index, 1);
119121

120122
if (!tmpArray.length) {
123+
this.attributesTmp = this.source.get('data.attributes');
121124
this.source.set('data.attributes', []);
125+
this.cacheGridData = [];
122126
}
123127

124128
if (parseInt(this.currentPage(), 10) === this.pages()) {
@@ -166,7 +170,7 @@ define([
166170
initObservable: function () {
167171
this._super()
168172
.observe([
169-
'insertDataFromGrid', 'unionInsertData', 'isEmpty', 'actionsListOpened'
173+
'insertDataFromGrid', 'unionInsertData', 'isEmpty', 'isShowAddProductButton', 'actionsListOpened'
170174
]);
171175

172176
return this;
@@ -197,9 +201,13 @@ define([
197201
var dataCount,
198202
elemsCount,
199203
tmpData,
200-
path;
204+
path,
205+
attributeCodes = this.source.get('data.attribute_codes');
201206

202207
this.isEmpty(data.length === 0);
208+
this.isShowAddProductButton(
209+
(!attributeCodes || data.length > 0 ? data.length : attributeCodes.length) > 0
210+
);
203211

204212
tmpData = data.slice(this.pageSize * (this.currentPage() - 1),
205213
this.pageSize * (this.currentPage() - 1) + this.pageSize);
@@ -260,6 +268,10 @@ define([
260268
tmpArray.push(mappedData);
261269
}, this);
262270

271+
// Attributes cannot be changed before regeneration thought wizard
272+
if (!this.source.get('data.attributes').length) {
273+
this.source.set('data.attributes', this.attributesTmp);
274+
}
263275
this.unionInsertData(tmpArray);
264276
},
265277

0 commit comments

Comments
 (0)