Skip to content

Commit d699ea8

Browse files
committed
Merge remote-tracking branch 'origin/AC-13866' into spartans_pr_12122025
2 parents 31258bf + 486ad78 commit d699ea8

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

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

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ define([
77
'underscore',
88
'uiRegistry',
99
'Magento_Ui/js/dynamic-rows/dynamic-rows',
10-
'jquery'
11-
], function (_, registry, dynamicRows, $) {
10+
'jquery',
11+
'mageUtils'
12+
], function (_, registry, dynamicRows, $, utils) {
1213
'use strict';
1314

1415
return dynamicRows.extend({
@@ -64,6 +65,28 @@ define([
6465
return this;
6566
},
6667

68+
/**
69+
* Get product type from URL
70+
*
71+
* @returns {String|null}
72+
*/
73+
getProductTypeFromUrl: function () {
74+
var urlParams = utils.getUrlParameters(window.location.href),
75+
urlPath = window.location.pathname;
76+
77+
if (urlPath.indexOf('/type/configurable') !== -1) {
78+
return 'configurable';
79+
}
80+
81+
// Check for type in URL parameters
82+
if (urlParams.type) {
83+
return urlParams.type;
84+
}
85+
86+
// For existing products, try to get from source
87+
return this.source.get('data.product.type_id') || null;
88+
},
89+
6790
/**
6891
* Change visibility
6992
*
@@ -204,15 +227,23 @@ define([
204227
elemsCount,
205228
tmpData,
206229
path,
207-
attributeCodes = this.source.get('data.attribute_codes');
230+
attributeCodes = this.source.get('data.attribute_codes'),
231+
productType = this.getProductTypeFromUrl();
208232

209233
this.isEmpty(data.length === 0);
210-
this.isShowAddProductButton(
211-
(!attributeCodes || data.length > 0 ? data.length : attributeCodes.length) > 0
212-
);
234+
235+
if (productType === 'configurable') {
236+
this.isShowAddProductButton(
237+
attributeCodes || attributeCodes.length > 0
238+
);
239+
} else {
240+
this.isShowAddProductButton(
241+
(!attributeCodes || data.length > 0 ? data.length : attributeCodes.length) > 0
242+
);
243+
}
213244

214245
tmpData = data.slice(this.pageSize * (this.currentPage() - 1),
215-
this.pageSize * (this.currentPage() - 1) + parseInt(this.pageSize, 10));
246+
this.pageSize * (this.currentPage() - 1) + parseInt(this.pageSize, 10));
216247

217248
this.source.set(this.dataScope + '.' + this.index, []);
218249

0 commit comments

Comments
 (0)