In Magento, the terms "Qty" (Quantity) and "Salable Qty" (Salable Quantity) are related to inventory management, especially in Magento 2 with Multi-Source Inventory (MSI). These two values can sometimes differ due to how Magento handles inventory, reservations, and stock sources. If you're noticing discrepancies between "Qty" and "Salable Qty" and want to fix them, here's a detailed explanation and steps to resolve the issue.
Understanding Qty vs. Salable Qty
-
Qty (Quantity):
- This is the physical stock quantity of a product in a specific inventory source (e.g., a warehouse).
- It represents the total number of items available in a source, regardless of reservations or pending orders.
-
Salable Qty (Salable Quantity):
-
Why Differences Occur:
- Pending Orders: Items in carts or unshipped orders reserve stock, reducing Salable Qty but not Qty.
- Inventory Source Issues: If multiple inventory sources are misconfigured, the Salable Qty may not reflect the total Qty accurately.
- Data Inconsistencies: Bugs, manual database edits, or third-party extensions can cause discrepancies.
- Canceled/Abandoned Orders: If reservations are not cleared properly after order cancellations or cart abandonment, Salable Qty may be incorrect.
- Outdated Indexes: Magento uses indexes to calculate Salable Qty, and if these are not updated, discrepancies can occur.
Steps to Fix Qty and Salable Qty Differences
Step 1: Verify the Issue
-
Check Product in Admin:
- Go to
Catalog > Products in the Magento Admin Panel.
- Open the product in question and check the "Quantity" field under the "Inventory" section.
- Compare it with the "Salable Quantity" displayed in the same section.
-
Check Inventory Sources:
- If you're using MSI, go to
Stores > Inventory > Sources and verify the quantities assigned to each source for the product.
- Ensure the sources are correctly assigned to the stock (
Stores > Inventory > Stocks).
-
Check Reservations:
Step 2: Reindex Magento
Discrepancies can often be resolved by reindexing, as Magento relies on indexes to calculate Salable Qty.
- Run the following commands in the Magento root directory:
php bin/magento indexer:reindex
- Specifically, ensure the
inventory index is reindexed:
php bin/magento indexer:reindex inventory
- Clear the cache:
php bin/magento cache:clean
Step 3: Clear Stale Reservations
If reservations are not cleared properly (e.g., due to canceled orders or abandoned carts), you may need to clean up the inventory_reservation table.
-
Backup Your Database:
- Always back up your database before making direct changes.
-
Check for Stale Reservations:
-
Manually Clear Reservations (if needed):
-
Use Magento CLI to Compensate Reservations:
Step 4: Sync Inventory
If the Qty and Salable Qty are still out of sync, you may need to manually sync the inventory.
-
Update Qty:
- Go to
Catalog > Products, open the product, and update the "Quantity" field to the correct physical stock.
- Save the product.
-
Recalculate Salable Qty:
- After updating Qty, reindex and clear the cache to ensure Salable Qty is recalculated.
Step 5: Check for Bugs or Customizations
-
Third-Party Extensions:
-
Custom Code:
- Check for custom code or database triggers that might be modifying the
inventory_source_item, inventory_stock_*, or inventory_reservation tables.
-
Magento Bugs:
Step 6: Test on Frontend
- After making changes, verify the Salable Qty on the frontend by checking the product page.
- Add the product to the cart and place an order to ensure reservations are created correctly.
Step 7: Automate Regular Maintenance
To prevent future discrepancies:
- Schedule Reindexing:
- Set up a cron job to reindex Magento regularly:
php bin/magento cron:run
- Monitor Reservations:
- Periodically check the
inventory_reservation table for stale entries.
- Enable Stock Alerts:
- Configure low stock alerts to monitor inventory levels (
Stores > Configuration > Catalog > Inventory).
Additional Notes
- MSI Configuration: If you're using MSI, ensure all sources and stocks are properly configured. Misconfigurations can lead to incorrect Salable Qty calculations.
- Performance: For large catalogs, reindexing and reservation cleanup can be resource-intensive. Perform these tasks during off-peak hours.
- Professional Help: If the issue persists, consider consulting a Magento developer or support team, as the problem may require deeper debugging.
By following these steps, you should be able to identify and fix discrepancies between Qty and Salable Qty in Magento.