Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetAllStockIds.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $resourceConnection;
23 
27  public function __construct(ResourceConnection $resourceConnection)
28  {
29  $this->resourceConnection = $resourceConnection;
30  }
31 
35  public function execute(): array
36  {
37  $connection = $this->resourceConnection->getConnection();
38  $stockTable = $this->resourceConnection->getTableName(StockResourceModel::TABLE_NAME_STOCK);
39 
40  $select = $connection->select()->from($stockTable, StockSourceLink::STOCK_ID);
41 
42  $stockIds = $connection->fetchCol($select);
43  $stockIds = array_map('intval', $stockIds);
44 
45  return $stockIds;
46  }
47 }
__construct(ResourceConnection $resourceConnection)
$connection
Definition: bulk.php:13