Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddStockStatusToCollection.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
19  protected $stockHelper;
20 
25  public function __construct(
26  \Magento\CatalogInventory\Helper\Stock $stockHelper
27  ) {
28  $this->stockHelper = $stockHelper;
29  }
30 
37  public function beforeLoad(Collection $productCollection, $printQuery = false, $logQuery = false)
38  {
39  $this->stockHelper->addIsInStockFilterToCollection($productCollection);
40  return [$printQuery, $logQuery];
41  }
42 }
beforeLoad(Collection $productCollection, $printQuery=false, $logQuery=false)
__construct(\Magento\CatalogInventory\Helper\Stock $stockHelper)