Skip to content

Commit ecf5f41

Browse files
mslabkoduhon
authored andcommitted
MAGETWO-61355: Sorting by price column in admin doesn't count disabled products
1 parent 3aa0a16 commit ecf5f41

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Ui\DataProvider\Product;
7+
8+
/**
9+
* Collection which is used for rendering product list in the backend.
10+
*
11+
* Used for product grid and customizes behavior of the default Product collection for grid needs.
12+
*/
13+
class ProductCollection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
14+
{
15+
/**
16+
* Disables using of price index for grid rendering
17+
*
18+
* Admin area shouldn't use price index and should rely on actual product data instead.
19+
*
20+
* @codeCoverageIgnore
21+
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
22+
*/
23+
protected function _productLimitationJoinPrice()
24+
{
25+
$this->_productLimitationFilters->setUsePriceIndex(false);
26+
return $this->_productLimitationPrice(true);
27+
}
28+
}

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
<type name="Magento\Catalog\Model\ResourceModel\Attribute">
7979
<plugin name="invalidate_pagecache_after_attribute_save" type="Magento\Catalog\Plugin\Model\ResourceModel\Attribute\Save" />
8080
</type>
81+
<virtualType name="\Magento\Catalog\Ui\DataProvider\Product\ProductCollectionFactory" type="\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory">
82+
<arguments>
83+
<argument name="instanceName" xsi:type="string">\Magento\Catalog\Ui\DataProvider\Product\ProductCollection</argument>
84+
</arguments>
85+
</virtualType>
8186
<type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
8287
<arguments>
8388
<argument name="addFieldStrategies" xsi:type="array">
@@ -86,6 +91,7 @@
8691
<argument name="addFilterStrategies" xsi:type="array">
8792
<item name="store_id" xsi:type="object">Magento\Catalog\Ui\DataProvider\Product\AddStoreFieldToCollection</item>
8893
</argument>
94+
<argument name="collectionFactory" xsi:type="object">\Magento\Catalog\Ui\DataProvider\Product\ProductCollectionFactory</argument>
8995
</arguments>
9096
</type>
9197
<type name="Magento\Catalog\Model\Product\Action">

0 commit comments

Comments
 (0)