Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog-inventory
Model
Plugin
Layer.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\CatalogInventory\Model\Plugin
;
7
8
class
Layer
9
{
15
protected
$stockHelper
;
16
22
protected
$scopeConfig
;
23
28
public
function
__construct
(
29
\
Magento
\CatalogInventory\Helper\
Stock
$stockHelper
,
30
\
Magento
\Framework\
App
\Config\
ScopeConfigInterface
$scopeConfig
31
) {
32
$this->stockHelper =
$stockHelper
;
33
$this->scopeConfig =
$scopeConfig
;
34
}
35
45
public
function
beforePrepareProductCollection
(
46
\
Magento
\Catalog\Model\
Layer
$subject,
47
\
Magento
\Catalog\Model\
ResourceModel
\
Collection
\
AbstractCollection
$collection
48
) {
49
if
($this->
_isEnabledShowOutOfStock
()) {
50
return
;
51
}
52
$this->stockHelper->addIsInStockFilterToCollection(
$collection
);
53
}
54
60
protected
function
_isEnabledShowOutOfStock
()
61
{
62
return
$this->scopeConfig->isSetFlag(
63
'cataloginventory/options/show_out_of_stock'
,
64
\
Magento
\Store\Model\ScopeInterface::SCOPE_STORE
65
);
66
}
67
}
Magento\CatalogInventory\Model\Plugin
Definition:
ProductSearchTest.php:9
Magento\Framework\App
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
Magento\CatalogInventory\Helper\Stock
Definition:
Stock.php:26
Magento\CatalogInventory\Model\Plugin\Layer\__construct
__construct(\Magento\CatalogInventory\Helper\Stock $stockHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
Definition:
Layer.php:28
Magento\CatalogInventory\Model\Plugin\Layer\$scopeConfig
$scopeConfig
Definition:
Layer.php:22
Magento\Eav\Model\Entity\Collection\AbstractCollection
Definition:
AbstractCollection.php:23
Magento\CatalogInventory\Model\Plugin\Layer\beforePrepareProductCollection
beforePrepareProductCollection(\Magento\Catalog\Model\Layer $subject, \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection $collection)
Definition:
Layer.php:45
Magento
Magento\CatalogInventory\Model\Plugin\Layer\_isEnabledShowOutOfStock
_isEnabledShowOutOfStock()
Definition:
Layer.php:60
Magento\CatalogInventory\Model\Plugin\Layer
Definition:
Layer.php:8
Magento\Catalog\Model\ResourceModel\Product\Link\Collection
Definition:
Collection.php:15
Magento\CatalogInventory\Model\Plugin\Layer\$stockHelper
$stockHelper
Definition:
Layer.php:15
Magento\Framework\App\Config\ScopeConfigInterface
Definition:
ScopeConfigInterface.php:15
$collection
$collection
Definition:
catalog_category_with_apostrophe_rollback.php:17