6
6
7
7
namespace Magento \PageBuilder \Model \Catalog ;
8
8
9
+ use Magento \Catalog \Model \ResourceModel \Product \Collection ;
10
+ use Magento \Catalog \Model \ResourceModel \Product \CollectionFactory ;
9
11
use Magento \Framework \Exception \NoSuchEntityException ;
12
+ use Magento \Indexer \Model \Indexer ;
10
13
use Magento \TestFramework \Helper \Bootstrap ;
11
14
use Magento \Catalog \Api \CategoryRepositoryInterface ;
12
15
use Magento \CatalogWidget \Block \Product \ProductsList ;
17
20
class SortingTest extends \PHPUnit \Framework \TestCase
18
21
{
19
22
/**
20
- * @var \Magento\Catalog\Model\ResourceModel\Product\ CollectionFactory
23
+ * @var CollectionFactory
21
24
*/
22
25
private $ productCollectionFactory ;
23
26
24
27
/**
25
- * @var \Magento\PageBuilder\Model\Catalog\ Sorting
28
+ * @var Sorting
26
29
*/
27
30
private $ sortModel ;
28
31
@@ -32,7 +35,7 @@ class SortingTest extends \PHPUnit\Framework\TestCase
32
35
private $ categoryRepository ;
33
36
34
37
/**
35
- * @var \Magento\Indexer\Model\ Indexer
38
+ * @var Indexer
36
39
*/
37
40
protected $ indexer ;
38
41
@@ -53,7 +56,7 @@ protected function setUp()
53
56
{
54
57
$ objectManager = Bootstrap::getObjectManager ();
55
58
$ this ->productCollectionFactory = $ objectManager ->create (
56
- \ Magento \ Catalog \ Model \ ResourceModel \ Product \ CollectionFactory::class
59
+ CollectionFactory::class
57
60
);
58
61
$ this ->sortModel = $ objectManager ->create (Sorting::class);
59
62
$ this ->categoryRepository = $ objectManager ->create (
@@ -99,7 +102,7 @@ public function testSortOptions(array $productSortData)
99
102
'PB_VIRTUAL_PRODUCT,simple_second_website,simple1,simple2,simple3,bundle_product, ' .
100
103
'configurable,simple_11,simple_21,gift-card,grouped,simple_100000001, ' .
101
104
'simple_100000002,simple-with-fpt,downloadable-product-price-on-product, ' .
102
- 'downloadable-product-price-on-link '
105
+ 'downloadable-product-price-on-link,ZERO_QTY_IN_STOCK_PRODUCT,special_price_product '
103
106
]
104
107
]
105
108
),
@@ -149,6 +152,8 @@ public function productSortDataProvider1() : array
149
152
'bundle_product ' ,
150
153
'simple3 ' ,
151
154
'simple1 ' ,
155
+ 'special_price_product ' ,
156
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
152
157
'gift-card ' ,
153
158
'PB_VIRTUAL_PRODUCT ' ,
154
159
'PB_PRODUCT_CPR ' ,
@@ -165,6 +170,8 @@ public function productSortDataProvider1() : array
165
170
'PB_PRODUCT_CPR ' ,
166
171
'PB_VIRTUAL_PRODUCT ' ,
167
172
'gift-card ' ,
173
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
174
+ 'special_price_product ' ,
168
175
'simple1 ' ,
169
176
'simple3 ' ,
170
177
'bundle_product ' ,
@@ -193,9 +200,13 @@ public function productSortDataProvider1() : array
193
200
'simple_100000002 ' ,
194
201
'simple1 ' ,
195
202
'simple3 ' ,
196
- 'simple-with-fpt '
203
+ 'simple-with-fpt ' ,
204
+ 'special_price_product ' ,
205
+ 'ZERO_QTY_IN_STOCK_PRODUCT '
197
206
],
198
207
'name_descending ' => [
208
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
209
+ 'special_price_product ' ,
199
210
'simple-with-fpt ' ,
200
211
'simple3 ' ,
201
212
'simple1 ' ,
@@ -246,9 +257,13 @@ public function productSortDataProvider2() : array
246
257
'simple1 ' ,
247
258
'simple3 ' ,
248
259
'simple_100000001 ' ,
249
- 'simple_100000002 '
260
+ 'simple_100000002 ' ,
261
+ 'special_price_product ' ,
262
+ 'ZERO_QTY_IN_STOCK_PRODUCT '
250
263
],
251
264
'sku_descending ' => [
265
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
266
+ 'special_price_product ' ,
252
267
'simple_100000002 ' ,
253
268
'simple_100000001 ' ,
254
269
'simple3 ' ,
@@ -269,6 +284,7 @@ public function productSortDataProvider2() : array
269
284
],
270
285
'low_stock_first ' => [
271
286
'gift-card ' ,
287
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
272
288
'bundle_product ' ,
273
289
'configurable ' ,
274
290
'grouped ' ,
@@ -284,9 +300,11 @@ public function productSortDataProvider2() : array
284
300
'PB_VIRTUAL_PRODUCT ' ,
285
301
'simple1 ' ,
286
302
'simple3 ' ,
287
- 'C_PB_PRODUCT '
303
+ 'C_PB_PRODUCT ' ,
304
+ 'special_price_product '
288
305
],
289
306
'high_stock_first ' => [
307
+ 'special_price_product ' ,
290
308
'C_PB_PRODUCT ' ,
291
309
'simple3 ' ,
292
310
'simple1 ' ,
@@ -303,6 +321,7 @@ public function productSortDataProvider2() : array
303
321
'grouped ' ,
304
322
'configurable ' ,
305
323
'bundle_product ' ,
324
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
306
325
'gift-card '
307
326
],
308
327
],
@@ -323,6 +342,7 @@ public function productSortDataProvider3() : array
323
342
'price_high_to_low ' => [
324
343
'bundle_product ' ,
325
344
'1_PB_PRODUCT ' ,
345
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
326
346
'PB_VIRTUAL_PRODUCT ' ,
327
347
'simple_100000001 ' ,
328
348
'simple-with-fpt ' ,
@@ -335,6 +355,7 @@ public function productSortDataProvider3() : array
335
355
'simple3 ' ,
336
356
'simple1 ' ,
337
357
'configurable ' ,
358
+ 'special_price_product ' ,
338
359
'downloadable-product-price-on-link ' ,
339
360
'gift-card ' ,
340
361
'B_PB_PRODUCT '
@@ -343,6 +364,7 @@ public function productSortDataProvider3() : array
343
364
'B_PB_PRODUCT ' ,
344
365
'gift-card ' ,
345
366
'downloadable-product-price-on-link ' ,
367
+ 'special_price_product ' ,
346
368
'configurable ' ,
347
369
'simple1 ' ,
348
370
'simple3 ' ,
@@ -355,6 +377,7 @@ public function productSortDataProvider3() : array
355
377
'simple-with-fpt ' ,
356
378
'simple_100000001 ' ,
357
379
'PB_VIRTUAL_PRODUCT ' ,
380
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
358
381
'1_PB_PRODUCT ' ,
359
382
'bundle_product '
360
383
],
@@ -365,7 +388,9 @@ public function productSortDataProvider3() : array
365
388
'C_PB_PRODUCT ' ,
366
389
'PB_PRODUCT_CPR ' ,
367
390
'PB_VIRTUAL_PRODUCT ' ,
368
- 'gift-card '
391
+ 'gift-card ' ,
392
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
393
+ 'special_price_product '
369
394
],
370
395
'position_by_sku ' => [
371
396
'B_PB_PRODUCT ' ,
@@ -384,7 +409,9 @@ public function productSortDataProvider3() : array
384
409
'simple_100000002 ' ,
385
410
'simple-with-fpt ' ,
386
411
'downloadable-product-price-on-product ' ,
387
- 'downloadable-product-price-on-link '
412
+ 'downloadable-product-price-on-link ' ,
413
+ 'ZERO_QTY_IN_STOCK_PRODUCT ' ,
414
+ 'special_price_product ' ,
388
415
]
389
416
],
390
417
]
@@ -394,10 +421,10 @@ public function productSortDataProvider3() : array
394
421
/**
395
422
* Retrieve SKUs from array
396
423
*
397
- * @param \Magento\Catalog\Model\ResourceModel\Product\ Collection $collection
424
+ * @param Collection $collection
398
425
* @return array
399
426
*/
400
- private function getSkus (\ Magento \ Catalog \ Model \ ResourceModel \ Product \ Collection $ collection ): array
427
+ private function getSkus (Collection $ collection ): array
401
428
{
402
429
$ skus = [];
403
430
foreach ($ collection as $ product ) {
0 commit comments