@@ -206,26 +206,23 @@ public function testGetProductsWithTierPrice()
206
206
/**
207
207
* Test addAttributeToSort() with attribute 'is_saleable' works properly on frontend.
208
208
*
209
- * @dataProvider addAttributeToSortDataProvider
209
+ * @dataProvider addIsSaleableAttributeToSortDataProvider
210
210
* @magentoDataFixture Magento/Catalog/_files/multiple_products_with_non_saleable_product.php
211
211
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
212
212
* @magentoAppIsolation enabled
213
213
* @magentoAppArea frontend
214
214
*/
215
- public function testAddAttributeToSort (string $ productSku , string $ order )
215
+ public function testAddIsSaleableAttributeToSort (string $ productSku , string $ order )
216
216
{
217
- /** @var Collection $productCollection */
218
217
$ this ->collection ->addAttributeToSort ('is_saleable ' , $ order );
219
- self :: assertEquals (2 , $ this ->collection ->count ());
220
- self :: assertSame ($ productSku , $ this ->collection ->getFirstItem ()->getSku ());
218
+ $ this -> assertEquals (2 , $ this ->collection ->count ());
219
+ $ this -> assertEquals ($ productSku , $ this ->collection ->getFirstItem ()->getSku ());
221
220
}
222
221
223
222
/**
224
- * Provide test data for testAddAttributeToSort().
225
- *
226
223
* @return array
227
224
*/
228
- public function addAttributeToSortDataProvider ()
225
+ public function addIsSaleableAttributeToSortDataProvider (): array
229
226
{
230
227
return [
231
228
[
@@ -239,6 +236,42 @@ public function addAttributeToSortDataProvider()
239
236
];
240
237
}
241
238
239
+ /**
240
+ * Test addAttributeToSort() with attribute 'price' works properly on frontend.
241
+ *
242
+ * @dataProvider addPriceAttributeToSortDataProvider
243
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
244
+ * @magentoDataFixture Magento/Catalog/_files/simple_product_with_tier_price_equal_zero.php
245
+ * @magentoAppIsolation enabled
246
+ * @magentoDbIsolation disabled
247
+ * @magentoAppArea frontend
248
+ */
249
+ public function testAddPriceAttributeToSort (string $ productSku , string $ order )
250
+ {
251
+ $ this ->processor ->getIndexer ()->reindexAll ();
252
+ $ this ->collection ->setStoreId (1 );
253
+ $ this ->collection ->addAttributeToSort ('price ' , $ order );
254
+ $ this ->assertEquals (2 , $ this ->collection ->count ());
255
+ $ this ->assertEquals ($ productSku , $ this ->collection ->getFirstItem ()->getSku ());
256
+ }
257
+
258
+ /**
259
+ * @return array
260
+ */
261
+ public function addPriceAttributeToSortDataProvider (): array
262
+ {
263
+ return [
264
+ [
265
+ 'product_sku ' => 'simple ' ,
266
+ 'order ' => Collection::SORT_ORDER_DESC ,
267
+ ],
268
+ [
269
+ 'product_sku ' => 'simple-2 ' ,
270
+ 'order ' => Collection::SORT_ORDER_ASC ,
271
+ ]
272
+ ];
273
+ }
274
+
242
275
/**
243
276
* Checks a case if table for join specified as an array.
244
277
*
0 commit comments