Skip to content

Commit 7c852fa

Browse files
author
Stanislav Idolov
committed
Revert of AC-872
1 parent fe85257 commit 7c852fa

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

Lines changed: 12 additions & 8 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-
public const DEFAULT_PRODUCTS_COUNT = 10;
46+
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-
public const PAGE_VAR_NAME = 'np';
53+
const PAGE_VAR_NAME = 'np';
5454

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

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

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

7777
/**
78+
* Catalog product visibility
79+
*
7880
* @var Visibility
7981
*/
8082
protected $catalogProductVisibility;
8183

8284
/**
85+
* Product collection factory
86+
*
8387
* @var CollectionFactory
8488
*/
8589
protected $productCollectionFactory;
@@ -235,8 +239,8 @@ public function getCacheKeyInfo()
235239
*/
236240
public function getProductPriceHtml(
237241
Product $product,
238-
$priceType = null,
239-
$renderZone = \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
242+
$priceType = null,
243+
$renderZone = \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
240244
array $arguments = []
241245
) {
242246
if (!isset($arguments['zone'])) {
@@ -334,12 +338,12 @@ public function createCollection()
334338
$collection->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds());
335339

336340
/**
337-
* Change sorting attribute to position because created_at can be the same for products fastly created
341+
* Change sorting attribute to entity_id because created_at can be the same for products fastly created
338342
* one by one and sorting by created_at is indeterministic in this case.
339343
*/
340344
$collection = $this->_addProductAttributesAndPrices($collection)
341345
->addStoreFilter()
342-
->addAttributeToSort('position', 'asc')
346+
->addAttributeToSort('entity_id', 'desc')
343347
->setPageSize($this->getPageSize())
344348
->setCurPage($this->getRequest()->getParam($this->getData('page_var_name'), 1));
345349

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('position', 'asc')->willReturnSelf();
317+
$collection->expects($this->once())->method('addAttributeToSort')->with('entity_id', 'desc')->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)