Skip to content

Commit 41cf9e0

Browse files
committed
Merge remote-tracking branch 'origin/ac872' into GL_Mainline_PR_22122021
2 parents 7e76471 + bbd6ca3 commit 41cf9e0

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
4343
/**
4444
* Default value for products count that will be shown
4545
*/
46-
const DEFAULT_PRODUCTS_COUNT = 10;
46+
public const DEFAULT_PRODUCTS_COUNT = 10;
4747

4848
/**
4949
* Name of request parameter for page number value
5050
*
5151
* @deprecated @see $this->getData('page_var_name')
5252
*/
53-
const PAGE_VAR_NAME = 'np';
53+
public const PAGE_VAR_NAME = 'np';
5454

5555
/**
5656
* Default value for products per page
5757
*/
58-
const DEFAULT_PRODUCTS_PER_PAGE = 5;
58+
public const DEFAULT_PRODUCTS_PER_PAGE = 5;
5959

6060
/**
6161
* Default value whether show pager or not
6262
*/
63-
const DEFAULT_SHOW_PAGER = false;
63+
public const DEFAULT_SHOW_PAGER = false;
6464

6565
/**
6666
* Instance of pager block
@@ -75,15 +75,11 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
7575
protected $httpContext;
7676

7777
/**
78-
* Catalog product visibility
79-
*
8078
* @var Visibility
8179
*/
8280
protected $catalogProductVisibility;
8381

8482
/**
85-
* Product collection factory
86-
*
8783
* @var CollectionFactory
8884
*/
8985
protected $productCollectionFactory;
@@ -338,12 +334,12 @@ public function createCollection()
338334
$collection->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds());
339335

340336
/**
341-
* Change sorting attribute to entity_id because created_at can be the same for products fastly created
337+
* Change sorting attribute to position because created_at can be the same for products fastly created
342338
* one by one and sorting by created_at is indeterministic in this case.
343339
*/
344340
$collection = $this->_addProductAttributesAndPrices($collection)
345341
->addStoreFilter()
346-
->addAttributeToSort('entity_id', 'desc')
342+
->addAttributeToSort('position', 'asc')
347343
->setPageSize($this->getPageSize())
348344
->setCurPage($this->getRequest()->getParam($this->getData('page_var_name'), 1));
349345

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
314314
$collection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf();
315315
$collection->expects($this->once())->method('addUrlRewrite')->willReturnSelf();
316316
$collection->expects($this->once())->method('addStoreFilter')->willReturnSelf();
317-
$collection->expects($this->once())->method('addAttributeToSort')->with('entity_id', 'desc')->willReturnSelf();
317+
$collection->expects($this->once())->method('addAttributeToSort')->with('position', 'asc')->willReturnSelf();
318318
$collection->expects($this->once())->method('setPageSize')->with($expectedPageSize)->willReturnSelf();
319319
$collection->expects($this->once())->method('setCurPage')->willReturnSelf();
320320
$collection->expects($this->once())->method('distinct')->willReturnSelf();

0 commit comments

Comments
 (0)