Get Stock Data by stock id Multi Source Inventory(MSI) Magento 2.

Get Stock Data by given stock id for Multi-Source Inventory Magento 2.

Interface Magento\InventoryApi\Api\StockRepositoryInterface used to get stock repository information related data.

get(int $stockId) method used to fetch Stock data by stock id in MSI module Magento 2.3 and Higher version.

Pass Stock Id as Integer to fetch Stock Information.

Call function to fetch Stock Data,
$stockData = $this->getStockData();


You got the Stock name and Extension attribute related to MSI stocks.