7
7
8
8
namespace Magento \PageBuilder \Ui \DataProvider \Product ;
9
9
10
+ use Magento \Store \Model \Store ;
11
+
10
12
/**
11
13
* PageBuilder ProductCollection class for allowing store-agnostic collections
12
14
*/
13
15
class ProductCollection extends \Magento \Catalog \Model \ResourceModel \Product \Collection
14
16
{
15
- /**
16
- * Set store id even if it's equal to \Magento\Store\Model\Store::DEFAULT_STORE_ID to prevent inadvertent resetting
17
- * {@inheritdoc}
18
- */
19
- public function addStoreFilter ($ store = null )
20
- {
21
- if ($ store !== null && (int ) $ store === 0 ) {
22
- $ this ->setStoreId ($ store );
23
- }
24
-
25
- return parent ::addStoreFilter ($ store );
26
- }
27
-
28
17
/**
29
18
* Prevent usage of catalog index for querying visibility, as it relies on a specific store id.
30
- * Visibility condition is to be added later in plugin.
31
- * @see \Magento\PageBuilder\Plugin\CatalogWidget\Block\Product\ProductsListPlugin::aroundGetData
32
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
33
19
* {@inheritdoc}
34
20
*/
35
21
public function setVisibility ($ visibility )
36
22
{
23
+ if ($ this ->getStoreId () === Store::DEFAULT_STORE_ID ) {
24
+ $ this ->addAttributeToFilter ('visibility ' , $ visibility );
25
+ } else {
26
+ parent ::setVisibility ($ visibility );
27
+ }
28
+
37
29
return $ this ;
38
30
}
39
31
@@ -43,7 +35,7 @@ public function setVisibility($visibility)
43
35
*/
44
36
protected function _productLimitationJoinPrice ()
45
37
{
46
- $ this ->_productLimitationFilters ->setUsePriceIndex (false );
38
+ $ this ->_productLimitationFilters ->setUsePriceIndex ($ this -> getStoreId () !== Store:: DEFAULT_STORE_ID );
47
39
return $ this ->_productLimitationPrice (false );
48
40
}
49
41
}
0 commit comments