Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
AddIsInStockFilterToCollection Class Reference

Public Member Functions

 __construct (StockIndexTableNameResolverInterface $stockIndexTableProvider)
 
 execute ($collection, int $stockId)
 

Detailed Description

Adapt adding is in stock filter to collection for Multi Stocks.

Definition at line 17 of file AddIsInStockFilterToCollection.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( StockIndexTableNameResolverInterface  $stockIndexTableProvider)
Parameters
StockIndexTableNameResolverInterface$stockIndexTableProvider

Definition at line 27 of file AddIsInStockFilterToCollection.php.

29  {
30  $this->stockIndexTableProvider = $stockIndexTableProvider;
31  }

Member Function Documentation

◆ execute()

execute (   $collection,
int  $stockId 
)
Parameters
Collection$collection
int$stockId
Returns
void

Definition at line 38 of file AddIsInStockFilterToCollection.php.

39  {
40  $tableName = $this->stockIndexTableProvider->execute($stockId);
41 
42  $collection->getSelect()->join(
43  ['stock_status_index' => $tableName],
44  'e.sku = stock_status_index.sku',
45  []
46  )->where('stock_status_index.' . IndexStructure::IS_SALABLE . ' = ?', 1);
47  }
$tableName
Definition: trigger.php:13

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