Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Layer Class Reference

Public Member Functions

 __construct (\Magento\CatalogInventory\Helper\Stock $stockHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
 
 beforePrepareProductCollection (\Magento\Catalog\Model\Layer $subject, \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection $collection)
 

Protected Member Functions

 _isEnabledShowOutOfStock ()
 

Protected Attributes

 $stockHelper
 
 $scopeConfig
 

Detailed Description

Definition at line 8 of file Layer.php.

Constructor & Destructor Documentation

◆ __construct()

Parameters
\Magento\CatalogInventory\Helper\Stock$stockHelper
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig

Definition at line 28 of file Layer.php.

31  {
32  $this->stockHelper = $stockHelper;
33  $this->scopeConfig = $scopeConfig;
34  }

Member Function Documentation

◆ _isEnabledShowOutOfStock()

_isEnabledShowOutOfStock ( )
protected

Get config value for 'display out of stock' option

Returns
bool

Definition at line 60 of file Layer.php.

61  {
62  return $this->scopeConfig->isSetFlag(
63  'cataloginventory/options/show_out_of_stock',
64  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
65  );
66  }

◆ beforePrepareProductCollection()

beforePrepareProductCollection ( \Magento\Catalog\Model\Layer  $subject,
\Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection  $collection 
)

Before prepare product collection handler

Parameters
\Magento\Catalog\Model\Layer$subject
\Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection$collection
Returns
void @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 45 of file Layer.php.

48  {
49  if ($this->_isEnabledShowOutOfStock()) {
50  return;
51  }
52  $this->stockHelper->addIsInStockFilterToCollection($collection);
53  }

Field Documentation

◆ $scopeConfig

$scopeConfig
protected

Definition at line 22 of file Layer.php.

◆ $stockHelper

$stockHelper
protected

Definition at line 15 of file Layer.php.


The documentation for this class was generated from the following file: