Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddIsInStockFieldToCollection.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $stockIndexTableProvider;
23 
27  public function __construct(
28  StockIndexTableNameResolverInterface $stockIndexTableProvider
29  ) {
30  $this->stockIndexTableProvider = $stockIndexTableProvider;
31  }
32 
38  public function execute($collection, int $stockId)
39  {
40  $tableName = $this->stockIndexTableProvider->execute($stockId);
41 
42  $collection->getSelect()->join(
43  ['inventory_in_stock' => $tableName],
44  'e.sku = inventory_in_stock.sku',
45  []
46  )->where('inventory_in_stock.' . IndexStructure::IS_SALABLE . ' = ?', 1);
47  }
48 }
__construct(StockIndexTableNameResolverInterface $stockIndexTableProvider)
$tableName
Definition: trigger.php:13