📦 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
- Go to Catalog > Products
- Click on any product
- Scroll down to the Quantities section
- Set values like:
- Quantity
- Stock Status
- Manage Stock: Yes/No
- Notify for Quantity Below
- Save the product
🌍 Multi-Source Inventory (MSI)
Magento 2 allows you to assign products to multiple Sources and manage inventory by Stocks:
- Go to Stores > Sources to create locations
- Go to Stores > Stocks to group sources per website
- 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]);
🧠 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! 📦🎯