Skip to content

Commit efb475b

Browse files
committed
MAGETWO-70062: Product price filter in admin shows incorrect product amount
- Create separate product collection with customizations for Product Grid rendering - Use left join to price index to avoid unexpected filtration by product status in the Product Grid - Use CollectionFactory customized through virtual type for Product Grid rendering in order to avoid interface change for Product data provider
1 parent 51df1fe commit efb475b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 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 Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
14+
{
15+
/**
16+
* Join Product Price Table using left-join
17+
*
18+
* Customizes how price index joined to product collection in order to show disabled products in the list.
19+
* It's needed as price index by its nature contains only values for enabled products.
20+
* However, product grid requires to show all available products without any implicit filtering.
21+
*
22+
* @codeCoverageIgnore
23+
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
24+
*/
25+
protected function _productLimitationJoinPrice()
26+
{
27+
return $this->_productLimitationPrice(true);
28+
}
29+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
<type name="Magento\Catalog\Model\ResourceModel\Attribute">
7878
<plugin name="invalidate_pagecache_after_attribute_save" type="Magento\Catalog\Plugin\Model\ResourceModel\Attribute\Save" />
7979
</type>
80+
<virtualType name="\Magento\Catalog\Ui\DataProvider\Product\CollectionFactory" type="\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory">
81+
<arguments>
82+
<argument name="instanceName" xsi:type="string">\Magento\Catalog\Ui\DataProvider\Product\Collection</argument>
83+
</arguments>
84+
</virtualType>
8085
<type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
8186
<arguments>
8287
<argument name="addFieldStrategies" xsi:type="array">
@@ -85,6 +90,7 @@
8590
<argument name="addFilterStrategies" xsi:type="array">
8691
<item name="store_id" xsi:type="object">Magento\Catalog\Ui\DataProvider\Product\AddStoreFieldToCollection</item>
8792
</argument>
93+
<argument name="collectionFactory" xsi:type="object">\Magento\Catalog\Ui\DataProvider\Product\CollectionFactory</argument>
8894
</arguments>
8995
</type>
9096
<type name="Magento\Catalog\Model\Product\Action">

0 commit comments

Comments
 (0)