Magento 2 Inventory Management

📦 Magento 2 Inventory Management – Track Stock Smartly

Magento 2 offers a powerful Inventory Management system to help store owners manage stock levels, track product availability, and use multiple warehouses or sources through the Multi-Source Inventory (MSI) feature.

📊 Key Inventory Features

  • Stock Status: In Stock / Out of Stock
  • Quantity Management: Track product quantity
  • Multi-Source Inventory (MSI): Manage inventory across multiple locations
  • Notify for Quantity Below: Alerts for low stock levels

🛠️ Manage Inventory via Admin Panel

  1. Go to Catalog > Products
  2. Click on any product
  3. Scroll down to the Quantities section
  4. Set values like:
    • Quantity
    • Stock Status
    • Manage Stock: Yes/No
    • Notify for Quantity Below
  5. Save the product

🌍 Multi-Source Inventory (MSI)

Magento 2 allows you to assign products to multiple Sources and manage inventory by Stocks:

  1. Go to Stores > Sources to create locations
  2. Go to Stores > Stocks to group sources per website
  3. Assign products to specific sources with quantity values

💻 Update Inventory Programmatically

use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\InventoryApi\Api\SourceItemsSaveInterface;
use Magento\InventoryApi\Api\Data\SourceItemInterfaceFactory;

require __DIR__ . '/app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();

$productSku = 'test-sku';
$qty = 15;

$sourceItemFactory = $objectManager->get(SourceItemInterfaceFactory::class);
$sourceItemsSave = $objectManager->get(SourceItemsSaveInterface::class);

/** @var \Magento\InventoryApi\Api\Data\SourceItemInterface $sourceItem */
$sourceItem = $sourceItemFactory->create();
$sourceItem->setSourceCode('default'); // Or custom source code
$sourceItem->setSku($productSku);
$sourceItem->setQuantity($qty);
$sourceItem->setStatus(1); // 1 = In Stock

$sourceItemsSave->execute([$sourceItem]);

Try It Now

🧠 Tips & Best Practices

  • Use MSI for multi-warehouse setups
  • Set proper Notify for Quantity Below thresholds
  • Keep track of Backorders setting if allowed
  • Update stock programmatically for large catalogs

✅ Summary

  • Magento 2 Inventory helps track and manage stock levels efficiently
  • MSI supports multiple warehouses and complex logistics
  • You can manage inventory manually or programmatically

Inventory under control = Happy customers + Smooth operations! 📦🎯