resource = $resource; $this->stockIndexTableNameResolver = $stockIndexTableNameResolver; } /** * @inheritdoc */ public function execute(string $sku, int $stockId): ?array { $stockItemTableName = $this->stockIndexTableNameResolver->execute($stockId); $connection = $this->resource->getConnection(); $select = $connection->select() ->from( $stockItemTableName, [ GetStockItemDataInterface::QUANTITY => IndexStructure::QUANTITY, GetStockItemDataInterface::IS_SALABLE => IndexStructure::IS_SALABLE, ] ) ->where(IndexStructure::SKU . ' = ?', $sku); try { if ($connection->isTableExists($stockItemTableName)) { return $connection->fetchRow($select) ?: null; } return null; } catch (\Exception $e) { throw new LocalizedException(__( 'Could not receive Stock Item data' ), $e); } } }