diff --git a/app/code/Magento/InventoryIndexer/Model/ResourceModel/GetStockItemData.php b/app/code/Magento/InventoryIndexer/Model/ResourceModel/GetStockItemData.php index 90072ff48fa3..cc91d5617e9c 100644 --- a/app/code/Magento/InventoryIndexer/Model/ResourceModel/GetStockItemData.php +++ b/app/code/Magento/InventoryIndexer/Model/ResourceModel/GetStockItemData.php @@ -76,6 +76,8 @@ public function execute(string $sku, int $stockId): ?array GetStockItemDataInterface::IS_SALABLE => 'stock_status', ] )->where('product_id = ?', $productId); + + return $connection->fetchRow($select) ?: null; } else { $stockItemTableName = $this->stockIndexTableNameResolver->execute($stockId); $select->from( @@ -85,18 +87,16 @@ public function execute(string $sku, int $stockId): ?array GetStockItemDataInterface::IS_SALABLE => IndexStructure::IS_SALABLE, ] )->where(IndexStructure::SKU . ' = ?', $sku); - } - try { - if ($connection->isTableExists($stockItemTableName)) { - return $connection->fetchRow($select) ?: null; - } + 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); + return null; + } catch (\Exception $e) { + throw new LocalizedException(__('Could not receive Stock Item data'), $e); + } } } }