---
title: "How to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2"
url: "https://magecomp.com/blog/get-product-multi-source-inventory-programmatically-magento-2/"
date: "2023-02-20T17:56:58+00:00"
modified: "2025-02-13T11:53:27+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 275
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "How to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2. Learn more"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Update Specific Product Quantities using SOAP API?"
    url: "https://magecomp.com/blog/magento-2-update-specific-product-quantities-using-soap-api/"
  - title: "How to Create Custom Table via XML In Magento 2.3"
    url: "https://magecomp.com/blog/how-to-create-custom-table-via-xml-in-magento-2/"
  - title: "Best Magento 2 Alternate Hreflang Tags Extensions"
    url: "https://magecomp.com/blog/best-magento-2-alternate-hreflang-tags-extensions/"
---

# How to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2

_Published: February 20, 2023_  
_Author: Dhiren Vasoya_  

![How to Get Product Multi Source Inventory MSI Programmatically in Magento 2](https://magecomp.com/blog/wp-content/uploads/2023/02/How-to-Get-Product-Multi-Source-Inventory-MSI-Programmatically-in-Magento-2-1024x512.webp)

**Hello Magento Friends,**

In this blog, I will explain How to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-2.webp)](https://magecomp.com/services/hyva-theme-development/)

First, let’s understand what is Multi Source Inventory (MSI ) in Magento 2.
## Magento 2 Multi Source Inventory (MSI)
Multi Source Inventory helps to [**manage inventory**](https://magecomp.com/blog/how-to-manage-magento-2-inventory-management/) by location. Merchants can link inventories to one or multiple websites without third-party extensions or platforms. MSI improves inventory management irrespective of customer or warehouse location, product type or sales channel.
Let’s get back to the point and find out the method to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2.
## Steps to Get Product Multi Source Inventory (MSI) Programmatically in Magento 2:
**Step 1:** We are getting data in the root script. Move to the below file path.
**magento_root_directory\sourceinventory.php**

Now add the code as follows.
```
<?php
use MagentoFrameworkAppBootstrap;
use MagentoStoreModelScopeInterface;

require './app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);

$objectManager = $bootstrap->getObjectManager();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');

try
{

    $sku = 'simple product'; // item sku

    $sourceinventorys = $objectManager->get('MagentoInventoryCatalogAdminUiModelGetSourceItemsDataBySku');
    $data = $sourceinventorys->execute($sku);

    foreach ($data as $source)
    {
         echo "";
         print_r($source);
         echo "";
    }
}catch(Exception $e)
{
    print_r($e->getMessage());
}
```

[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-3.webp)](https://magecomp.com/services/hire-magento-programmer/)

**Output:**

[![](https://magecomp.com/blog/wp-content/uploads/2023/02/product-MSI-magento-2.png)](https://magecomp.com/blog/wp-content/uploads/2023/02/product-MSI-magento-2.png)

## Conclusion:
Hence, this way, you can Get Product Multi Source Inventory (MSI) Programmatically in Magento 2. If you have any doubts, let me know through the comment box and share the article with your friends. See you in the next tutorial; till then, stay with us!
[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-3.webp)](https://magecomp.com/services/magento-upgrade-services/)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/get-product-multi-source-inventory-programmatically-magento-2/](https://magecomp.com/blog/get-product-multi-source-inventory-programmatically-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-27 15:20:45 UTC_  
