/** * {@inheritDoc} */ public function beforePrepareProductCollection(\Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection $collection) { if ($this->_isEnabledShowOutOfStock() === false) { $collection->addIsInStockFilter(); } $this->setSortParams($layer, $collection); }