Skip to content

Commit 9687f71

Browse files
committed
Merge remote-tracking branch 'origin/1.2.0-release' into PB-261-120
2 parents 81f2312 + a42ca83 commit 9687f71

File tree

6 files changed

+34
-61
lines changed

6 files changed

+34
-61
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ public function execute()
5454
$conditions = $this->getRequest()->getParam('conditionValue');
5555

5656
try {
57-
$totals = $this->productTotals->getProductTotals($conditions);
58-
$response = [
59-
'total' => $totals['total'],
60-
'disabled' => $totals['disabled'],
61-
'notVisible' => $totals['notVisible'],
62-
'outOfStock' => $totals['outOfStock'],
63-
];
57+
$response = $this->productTotals->getProductTotals($conditions);
6458
} catch (Exception $e) {
6559
$response = [
6660
'total' => 0,
6761
'disabled' => 0,
6862
'notVisible' => 0,
69-
'outOfStock' => 0,
7063
];
7164
}
7265

app/code/Magento/PageBuilder/Model/Catalog/ProductTotals.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Catalog\Model\Product\Visibility;
1313
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1414
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
15-
use Magento\CatalogInventory\Helper\Stock;
1615
use Magento\CatalogWidget\Model\Rule;
1716
use Magento\Framework\Exception\LocalizedException;
1817
use Magento\Rule\Model\Condition\Combine;
@@ -45,30 +44,22 @@ class ProductTotals
4544
*/
4645
private $conditionsHelper;
4746

48-
/**
49-
* @var Stock
50-
*/
51-
private $stockFilter;
52-
5347
/**
5448
* @param CollectionFactory $productCollectionFactory
5549
* @param Builder $sqlBuilder
5650
* @param Rule $rule
5751
* @param Conditions $conditionsHelper
58-
* @param Stock $stockFilter
5952
*/
6053
public function __construct(
6154
CollectionFactory $productCollectionFactory,
6255
Builder $sqlBuilder,
6356
Rule $rule,
64-
Conditions $conditionsHelper,
65-
Stock $stockFilter
57+
Conditions $conditionsHelper
6658
) {
6759
$this->productCollectionFactory = $productCollectionFactory;
6860
$this->sqlBuilder = $sqlBuilder;
6961
$this->rule = $rule;
7062
$this->conditionsHelper = $conditionsHelper;
71-
$this->stockFilter = $stockFilter;
7263
}
7364

7465
/**
@@ -155,34 +146,6 @@ private function getNotVisibleCount(Collection $baseCollection): int
155146
return $notVisibleCollection->getSize();
156147
}
157148

158-
/**
159-
* Retrieve count of all out of stock products
160-
*
161-
* @param Collection $baseCollection
162-
* @return int number of out of stock products
163-
* @throws Zend_Db_Select_Exception
164-
*/
165-
private function getOutOfStockCount(Collection $baseCollection): int
166-
{
167-
// Retrieve in stock products, then subtract them from the total
168-
$outOfStockCollection = clone $baseCollection;
169-
$this->stockFilter->addIsInStockFilterToCollection($outOfStockCollection);
170-
// Remove existing stock_status where condition from query
171-
$outOfStockWhere = $outOfStockCollection->getSelect()->getPart('where');
172-
$outOfStockWhere = array_filter(
173-
$outOfStockWhere,
174-
function ($whereCondition) {
175-
return !stristr($whereCondition, 'stock_status');
176-
}
177-
);
178-
$outOfStockCollection->getSelect()->setPart('where', $outOfStockWhere);
179-
$outOfStockCollection->getSelect()->where(
180-
'stock_status_index.stock_status = ?',
181-
\Magento\CatalogInventory\Model\Stock\Status::STATUS_OUT_OF_STOCK
182-
);
183-
return $outOfStockCollection->getSize();
184-
}
185-
186149
/**
187150
* Retrieve product totals for collection
188151
*
@@ -209,13 +172,11 @@ public function getProductTotals(string $conditions): array
209172

210173
$disabledCount = $this->getDisabledCount($collection);
211174
$notVisibleCount = $this->getNotVisibleCount($collection);
212-
$outOfStockCount = $this->getOutOfStockCount($collection);
213175

214176
return [
215177
'total' => $collection->getSize(),
216178
'disabled' => $disabledCount,
217179
'notVisible' => $notVisibleCount,
218-
'outOfStock' => $outOfStockCount,
219180
];
220181
}
221182
}

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderProductsCommonTests.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@
11751175
<argument name="category" value="$$createCategory1.name$$"/>
11761176
</actionGroup>
11771177
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanelAgain1">
1178-
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible, 1 out of stock)"/>
1178+
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible)"/>
11791179
</actionGroup>
11801180
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel1"/>
11811181
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage1">
@@ -1190,7 +1190,7 @@
11901190
<argument name="property" value="PageBuilderProductsProductCarouselAppearance"/>
11911191
</actionGroup>
11921192
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanel2">
1193-
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible, 1 out of stock)"/>
1193+
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible)"/>
11941194
</actionGroup>
11951195
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel2"/>
11961196
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage2">
@@ -1209,7 +1209,7 @@
12091209
<argument name="SKUs" value="$$createDisabledProduct.sku$$,$$createProduct1.sku$$,$$createOutOfStockProduct.sku$$,$$createNotVisibleProduct.sku$$"/>
12101210
</actionGroup>
12111211
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanelAgain3">
1212-
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible, 1 out of stock)"/>
1212+
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible)"/>
12131213
</actionGroup>
12141214
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel3"/>
12151215
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage3">
@@ -1224,7 +1224,7 @@
12241224
<argument name="property" value="PageBuilderProductsProductGridAppearance"/>
12251225
</actionGroup>
12261226
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanel4">
1227-
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible, 1 out of stock)"/>
1227+
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible)"/>
12281228
</actionGroup>
12291229
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel4"/>
12301230
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage4">

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,22 @@
229229
<settings>
230230
<elementTmpl>Magento_PageBuilder/form/element/product-totals</elementTmpl>
231231
<dataType>text</dataType>
232+
<additionalClasses>
233+
<class name="admin__field-product-tooltip">true</class>
234+
</additionalClasses>
235+
<tooltip>
236+
<description translate="true">
237+
<![CDATA[
238+
<p>The products displayed may vary from this total due to several factors, including but not limited to:</p>
239+
<ul>
240+
<li>Disabled status</li>
241+
<li>Visibility configuration (not visible in catalog)</li>
242+
<li>Stock availability (out of stock)</li>
243+
<li>Website assignment</li>
244+
</ul>
245+
]]>
246+
</description>
247+
</tooltip>
232248
<imports>
233249
<link name="conditionOption">ns = ${ $.ns }, index = condition_option:value</link>
234250
<link name="conditionValue">ns = ${ $.ns }, index = conditions_form:value</link>

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/products/_default.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@
322322
}
323323
}
324324

325+
.admin__field-product-tooltip {
326+
[data-role='spinner'] {
327+
display: inline-block;
328+
}
329+
330+
.admin__field-tooltip-content ul {
331+
padding-left: 17px;
332+
padding-top: 10px;
333+
}
334+
}
335+
325336
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__xl) {
326337
.pagebuilder-products {
327338
.product-item {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ define([
2020
totalProductCount: 0,
2121
totalDisabledProducts: 0,
2222
totalNotVisibleProducts: 0,
23-
totalOutOfStockProducts: 0,
2423
previousConditions: false,
2524
listens: {
2625
conditionOption: 'updateProductTotals',
@@ -37,7 +36,6 @@ define([
3736
valuePlaceholder: $t('of %1 total'),
3837
disabledPlaceholder: $t('%1 disabled'),
3938
notVisiblePlaceholder: $t('%1 not visible'),
40-
outOfStockPlaceholder: $t('%1 out of stock'),
4139
showSpinner: true,
4240
loading: false,
4341
jqXHR: null
@@ -55,8 +53,7 @@ define([
5553
/** @inheritdoc */
5654
initObservable: function () {
5755
return this._super()
58-
.observe('value totalProductCount totalDisabledProducts totalNotVisibleProducts ' +
59-
'totalOutOfStockProducts loading');
56+
.observe('value totalProductCount totalDisabledProducts totalNotVisibleProducts loading');
6057
},
6158

6259
/**
@@ -111,7 +108,6 @@ define([
111108
this.totalProductCount(parseInt(response.total, 10));
112109
this.totalDisabledProducts(parseInt(response.disabled, 10));
113110
this.totalNotVisibleProducts(parseInt(response.notVisible, 10));
114-
this.totalOutOfStockProducts(parseInt(response.outOfStock, 10));
115111
totalText = this.valuePlaceholder
116112
.replace('%1', parseInt(response.total, 10));
117113

@@ -123,10 +119,6 @@ define([
123119
negativeTotals.push(this.notVisiblePlaceholder.replace('%1', parseInt(response.notVisible, 10)));
124120
}
125121

126-
if (parseInt(response.outOfStock, 10) > 0) {
127-
negativeTotals.push(this.outOfStockPlaceholder.replace('%1', parseInt(response.outOfStock, 10)));
128-
}
129-
130122
if (negativeTotals.length > 0) {
131123
totalText += ' (' + negativeTotals.join(', ') + ')';
132124
}

0 commit comments

Comments
 (0)