Skip to content

Commit 9ad10b6

Browse files
committed
PB-107: Display total number of products matched into ProductsList
- populate total number of products
1 parent a1558f6 commit 9ad10b6

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/product-totals.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
define([
77
'underscore',
88
'jquery',
9+
'mage/translate',
910
'Magento_PageBuilder/js/form/provider/conditions-data-processor',
1011
'Magento_Ui/js/form/element/abstract'
11-
], function (_, $, conditionsDataProcessor, Abstract) {
12+
], function (_, $, $t, conditionsDataProcessor, Abstract) {
1213
'use strict';
1314

1415
return Abstract.extend({
@@ -29,7 +30,8 @@ define([
2930
links: {
3031
value: false
3132
},
32-
url: null
33+
url: null,
34+
valuePlaceholder: $t('of %1 (%2 disabled)')
3335
},
3436

3537
/** @inheritdoc */
@@ -43,7 +45,6 @@ define([
4345
*
4446
*/
4547
updateProductTotals: _.debounce(function () {
46-
4748
if (!this.conditionOption || _.isEmpty(this.formData) ||
4849
(this.conditionOption === 'sku' && (!this.formData['sku'] || this.formData['sku'] === ''))) {
4950
return;
@@ -63,10 +64,17 @@ define([
6364
conditionValue: this.formData['conditions_encoded']
6465
}
6566
}).done(function (response) {
66-
this.totalProductCount = response['total'];
67-
this.totalDisabledProducts = response['disabled'];
68-
this.value('of ' + this.totalProductCount + ' (' + this.totalDisabledProducts + ' disabled)');
69-
}.bind(this));
67+
this.totalProductCount(response['total']);
68+
this.totalDisabledProducts(response['disabled']);
69+
this.value(
70+
this.valuePlaceholder
71+
.replace('%1', this.totalProductCount())
72+
.replace('%2', this.totalDisabledProducts())
73+
);
74+
}.bind(this)
75+
).fail(() => {
76+
this.value($t("An unknown error occurred. Please try again."));
77+
});
7078
}, 10),
7179
});
7280
});

0 commit comments

Comments
 (0)