Skip to content

Commit 75c8616

Browse files
committed
PB-107: Display total number of products matched into ProductsList
- populate total number of products
1 parent 5cade68 commit 75c8616

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductTotals.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ private function createCollection()
134134
public function execute()
135135
{
136136
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
137-
$collection = $this->createCollection();
137+
$collection = $this->createCollection()
138+
->getSelect()->joinLeft(
139+
['link_table' => $collection->getTable('catalog_product_super_link')],
140+
'link_table.product_id = e.entity_id',
141+
['product_id']
142+
)->where('link_table.product_id IS NULL');
138143
$totalProducts = $collection->getSize();
139144
$disabledProducts = $collection
140145
->addAttributeToFilter('status', Status::STATUS_DISABLED)

app/code/Magento/PageBuilder/view/adminhtml/ui_component/pagebuilder_products_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
</item>
228228
</argument>
229229
<settings>
230-
<elementTmpl>ui/form/element/text</elementTmpl>
230+
<elementTmpl>Magento_PageBuilder/form/element/product-totals</elementTmpl>
231231
<dataType>text</dataType>
232232
<imports>
233233
<link name="conditionOption">ns = ${ $.ns }, index = condition_option:value</link>

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/form/element/_import.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
@import '_margins-and-padding.less';
1313
@import 'uploader/preview/_image.less';
1414
@import '_visual-select.less';
15+
@import '_product-totals.less';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
6+
.admin__data-grid-loading-mask {
7+
font-size: 2em;
8+
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@ define([
3131
value: false
3232
},
3333
url: null,
34-
valuePlaceholder: $t('of %1 (%2 disabled)')
34+
valuePlaceholder: $t('of %1 (%2 disabled)'),
35+
showSpinner: true,
36+
loading: false
3537
},
3638

3739
/** @inheritdoc */
3840
initObservable: function () {
3941
return this._super()
40-
.observe('value totalProductCount totalDisabledProducts');
42+
.observe('value totalProductCount totalDisabledProducts loading');
4143
},
4244

4345
/**
4446
* Update product count.
4547
*
4648
*/
4749
updateProductTotals: _.debounce(function () {
48-
if (!this.conditionOption || _.isEmpty(this.formData) ||
49-
(this.conditionOption === 'sku' && (!this.formData['sku'] || this.formData['sku'] === ''))) {
50+
if (!this.conditionOption || _.isEmpty(this.formData)) {
5051
return;
5152
}
5253

@@ -57,6 +58,7 @@ define([
5758
_.extend(this.formData, this.conditionValue);
5859
conditionsDataProcessor(this.formData, this.conditionOption + '_source');
5960

61+
this.loading(true);
6062
$.ajax({
6163
url: this.url,
6264
method: 'POST',
@@ -71,9 +73,11 @@ define([
7173
.replace('%1', this.totalProductCount())
7274
.replace('%2', this.totalDisabledProducts())
7375
);
76+
this.loading(false);
7477
}.bind(this)
7578
).fail(function () {
7679
this.value($t('An unknown error occurred. Please try again.'));
80+
this.loading(false);
7781
}.bind(this));
7882
}, 10),
7983
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div data-role="spinner"
8+
class="admin__data-grid-loading-mask"
9+
visible="loading"
10+
if="showSpinner">
11+
<div class="spinner">
12+
<span repeat="8"/>
13+
</div>
14+
</div>
15+
<span class="admin__field-value"
16+
data-bind="
17+
text: value,
18+
attr: {
19+
name: inputName,
20+
id: uid
21+
}">
22+
</span>

0 commit comments

Comments
 (0)