Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetAssignedStockIds.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(
28  ResourceConnection $resourceConnection
29  ) {
30  $this->resourceConnection = $resourceConnection;
31  }
32 
37  public function execute(array $sourceCodes): array
38  {
39  $connection = $this->resourceConnection->getConnection();
40  $sourceStockLinkTable = $this->resourceConnection->getTableName(
41  StockSourceLinkResourceModel::TABLE_NAME_STOCK_SOURCE_LINK
42  );
43 
45  ->select()
46  ->from($sourceStockLinkTable, StockSourceLink::STOCK_ID)
47  ->where(StockSourceLink::SOURCE_CODE . ' IN (?)', $sourceCodes)
49 
50  $stockIds = $connection->fetchCol($select);
51  $stockIds = array_map('intval', $stockIds);
52  return $stockIds;
53  }
54 }
$connection
Definition: bulk.php:13