Magento 2 Inventory Reservation: Resolve Inconsistencies
Looking to improve how you manage inventory in Magento 2? Magento 2 inventory reservation ensures accurate stock levels during order placement and fulfillment.
This article will cover advanced techniques of inventory reservation in Magento 2.
Key Takeaways
- Manage, monitor, and resolve reservation inconsistencies.
- Reserve inventory across multiple sources and stock levels.
- Configure inventory settings, detect inconsistencies, and resolve issues with MSI.
- Ensure a seamless shopping experience for your customers.
- Create reservations when customers add items to carts or place orders.
- Improve overall inventory management and efficient operations for your business.
-
How To Configure Inventory Management For Quantities and Reservations?
-
How To Detect And Manage Reservation Inconsistencies In Magento Inventory?
-
Detail Order Status And Reservation Compensations In Magento
-
How To Calculate And Update Your Scalable Quantity Per Source & Reservation In Magento?
-
What Are Reservation Objects And Reservation Lifecycle In Magento?
How To Configure Inventory Management For Quantities and Reservations?
Reservations place holds on inventory quantities. It reduces the available salable quantity when an order is submitted. These reservations affect stock levels and are counted against inventory. This process happens until the order is invoiced and shipped or canceled. During the shipping process, you can either follow SSA recommendations. Or manually enter quantity deductions based on the source. Once the order is shipped, the reservations are automatically cleared. The deducted quantities are also updated. The salable quantity for the stock is recalculated to reflect the updated amount. It also considers any remaining reservation amounts in the system.
When a customer places an order, Commerce verifies the current inventory salable quantity. If sufficient inventory is available, a reservation is made. You can place a temporary hold on the product SKU (for that stock). You can also adjust the salable quantity accordingly.
Once the order is invoiced, you will determine how much product to deduct and ship from your sources. The shipment is processed and dispatched. It goes from one or more selected sources to the customer. The quantities are automatically deducted from the source inventory. The reservations are also cleared.
How To Detect And Manage Reservation Inconsistencies In Magento Inventory?
Inventory Management generates reservations during key events such as:
- Order placement (initial reservation)
- Order shipment (compensation reservation)
- Refund or credit memo issuance (compensation reservation)
- Order cancellation (compensation reservation)
Reservation inconsistencies occur when the inventory management loses the initial reservation. Or applies too many compensation reservations. It results in overcompensation. It can also be due to the successful placement of the initial reservation. However, it fails to apply the necessary compensation reservations.
Several factors can lead to these inconsistencies, including:
1. Upgrading Magento to 2.3.x with incomplete orders
Inventory management creates compensational reservations. It occurs if orders are not marked as "Complete", "Canceled", or "Closed". It happens without the initial reservation that deducts the value from the salable quantity. It’s recommended to run specific commands after upgrading from Magento 2.1.x or 2.2.x. It helps to ensure pending orders are updated correctly.
2. Changing stock management setting
Reservations won't be placed during order and shipment events. It happens when you start using 2.3.x with Manage Stock set to "No". Enabling this configuration later can lead to corrupted salable quantities. This is because compensation reservations are added for orders created during this period.
3. Reassigning stock to a website with active orders
If stock is reassigned while orders are still being processed, the initial reservation may be applied to the old stock. However, compensation reservations will be applied to the new stock. It creates inconsistencies.
To prevent these issues,
- MSI offers two CLI commands to identify and fix reservation inconsistencies:
inventory:reservation:list-inconsistencies
inventory:reservation:create-compensations
- Ensure all reservations in the scope of completed orders resolve to "0".
For example, Complete, Canceled, or Closed. It clears all salable quantity holds.
Note: Compensation reservations are placed or cleared to maintain accurate stock levels. It takes place during shipping, adding products, canceling, or refunding an order.
Follow these 3 steps to solve Adobe Commerce and Magento Open Source compensatory reservations:
4. List Inconsistencies Command
The list-inconsistencies
command identifies and displays all reservation inconsistencies. You can use specific options to focus on completed, incomplete, or all orders.
bin/magento inventory:reservation:list-inconsistencies
Command Options
- -c, --complete-orders: Lists inconsistencies for "completed orders". Here, incorrect reservations may still be on hold.
- -i, --incomplete-orders: Lists inconsistencies for "incomplete orders". For example, partially shipped or unshipped. Here, salable quantities might be incorrect.
- -b, --bunch-size: Specifies how many orders to load at a time.
-
-r, --raw: Provides raw output in the format
<ORDER_INCREMENT_ID>:<SKU>:<QUANTITY>:<STOCK-ID>
.
5. Create Compensations Command
The create-compensations
command generates new compensation reservations. These reservations either place or release holds on salable quantities. It does this based on the detected issues.
To create reservations, use the format <ORDER_INCREMENT_ID>:<SKU>:<QUANTITY>:<STOCK-ID>
, like this:
bin/magento inventory:reservation:create-compensations
Command Option
- -r, --raw: Displays raw output.
-
Detect and Create Compensations
You can detect inconsistencies and immediately create compensations. You can do this by piping the list-inconsistencies
and create-compensations
commands together. Use the -r
option to pass raw data between the commands.
For example,
bin/magento inventory:reservation:list-inconsistencies -r | bin/magento inventory:reservation:create-compensations
Detail Order Status And Reservation Compensations In Magento
Order Status | Description | Reservation Impact on Salable Quantity |
---|---|---|
Open | New order submitted, no processing | Reservation created to save stock for the order |
Canceled | Canceled before payment | Reservation compensation added to return quantity to stock salable quantity |
On Hold | Payment and shipping not processed | Reservation remains in place |
Suspected Fraud | Under review due to fraud concerns | Reservation stays in place until a decision is made |
Pending | Waiting for payment | Reservation remains in place |
Processing | Payment processing, not received | Reservation stays in place |
Pending Payment | Payment not received | Reservation remains in place |
Payment Review | Payment being reviewed | Reservation stays in place |
Complete | Paid and shipped in full | Reservation deducted from product quantity when invoiced; compensation entered to update salable quantity |
Closed | Refunded or archived | Reservation compensation entered if refunded; no change if archived |
How To Calculate And Update Your Scalable Quantity Per Source & Reservation In Magento?
Magento generates a reservation for each product when the following events occur:
- A customer or merchant places an order.
- A customer or merchant cancels an order, either fully or partially.
- The merchant creates a shipment for a physical product.
- The merchant generates an invoice for a virtual or downloadable product.
- The merchant issues a credit memo.
Reservations are append-only operations, similar to an event log. The initial reservation is recorded as a negative quantity. However, all subsequent reservations created during order processing are positive. Once the order is complete, the sum of all reservations is "0".
Magento checks if there are enough salable items to fulfill the order. Before issuing a reservation for a new order, the following factors are considered:
- StockItem quantity: This is the combined total inventory from all physical sources for the sales channel.
For example, if the Baltimore source has "20 units", the Austin source has "25", and the Reno source has "10", all sources are linked to Stock A. For this calculation:
Total StockItem Quantity for the product = 55 (20 + 25 + 10).
When items are shipped, the Inventory indexer updates the available quantities at each source.
- Outstanding reservations: Magento totals all the initial reservations that haven't been compensated. These are usually a negative number. For instance, 'Customer A' has a reservation for "10 items" and 'Customer B' has one for "5 items". Here,
Outstanding Reservations total - 15.
As a result, a merchant can fulfill an incoming order if:
Order Quantity < 40 (55 - 15) units.
The following settings can influence the calculation of salable quantities:
- Backorders (with Out-of-Stock Thresholds)
- Notify for Quantity Below Threshold
Stock Options For Placing Reservations At Order Placement
Depending on inventory status and customer requests, you may need to manage orders by:
- Processing partial payments
- Handling cancellations
- Arranging partial shipments from multiple sources or backorders
- Issuing credit memos for refunded products
1. Shipments
After invoicing, you can dispatch partial or complete shipments until the entire order is fulfilled. Each shipment converts reservations. It deducts the corresponding quantity from the product stock per source. These reservation adjustments update the salable quantity of your inventory. For partial shipments, the deducted amount is adjusted from your product quantity & reservations. Any unshipped reservations remain until the products are shipped later. It ensures your salable quantity remains accurate, allowing control over inventory. It supports multiple source shipments and handles backorders.
2. Canceled Orders
A new reservation is created to return the inventory to the salable quantity. It occurs when a customer cancels an order before shipment. It can happen either partially or completely. The cancellations effectively offset the original reservations. It makes sure "no quantities" are deducted from any sources. The canceled products become available for other customers. They can purchase them through the relevant stocks and sales channels.
3. Refunded Orders
Refunded orders and inventory reservation adjustments in Magento 2 to maintain accurate stock across sources
For a customer refund request, issue a credit memo for the partial or total amount of the returned products. Upon receiving the returned items, create a credit memo to refund the amount. Update the product quantities, too. Also, select the "Return to Stock" option. This way, Magento adds the returned quantities back to the products. It also adds the sources that initially shipped the orders. It then updates the salable quantities accordingly.
4. Simple orders
Simple orders start with:
- Adding items to a shopping cart
- Proceeding to payment
- Concluding with a successful delivery
In these cases, inventory management efficiently handles reservations. It handles them against the cart's availability or salable quantity. It also adjusts the on-hand inventory at the time of shipment.
5. Complicated Orders
Complicated orders might involve:
- Partial cancellations
- Partial shipments
- Refunds
In such scenarios, reservations impact the available inventory. It increases quantities for cancellations and refunds. Or decrease quantities for orders and shipments.
What Are Reservation Objects And Reservation Lifecycle In Magento?
Reservation Object
A reservation holds the following details:
Parameter | Data Type | Description |
---|---|---|
reservation_id | Integer | A system-generated ID. |
stock_id | Integer | The ID of the stock assigned to the product. |
sku | String | The SKU of the product. |
quantity | Float | The number of items included in this reservation. |
metadata | String | Contains event type, object type, and object ID. For example: {"event_type":"order_placed","object_type":"order","object_id":"8"} . |
The event_type
in the metadata can take on the following values:
-
order_placed
-
order_canceled
-
shipment_created
-
creditmemo_created
-
invoice_created
Currently, the object_type
is limited to "order". The object_id
represents the "order ID". Future updates may allow reservations when customers add items to their shopping carts. They can also add items reserved for a fixed period. For example, "15 minutes". The metadata would then expand to include more information.
Reservation Lifecycle
Here’s an example of the reservation process for a simple order:
- A customer places an order for "25 units" of product
SKU-1
. The reservation details are:
reservation_id = 1 stock_id = 1 sku = SKU-1 quantity = -25 event_type = order_placed
- The customer cancels "5 units", invoicing only "20". This cancellation results in:
reservation_id = 2 stock_id = 1 sku = SKU-1 quantity = 5 event_type = order_canceled
- The merchant ships the remaining "20 units":
reservation_id = 3 stock_id = 1 sku = SKU-1 quantity = 20 event_type = shipment_created
Sum of these three reservations = 0 (-25 + 5 + 20).
Note: Magento does not modify any existing reservations.
How To Remove Processed Reservations In Magento 2?
Magento offers the inventory_cleanup_reservations
cron job to manage the reservation table. By default, this cron job executes daily at midnight. However, you can adjust its schedule as needed. The job runs a script that searches the database for complete reservation sequences. Here, the total quantity value is "zero". Once all reservations for a particular product are created on the same day, Magento deletes these reservations in bulk. It can also be within another configured timeframe, or once it has been compensated.
Not all initial reservations produced on a given day can be compensated within the same day. IIt could happen if a customer places an order before the cron job runs. Or uses an offline payment method, like a "bank transfer". Until all reservations have been compensated, the sequences remain in the database. However, since their total quantity is "zero", it does not impact reservation calculations.
FAQs
1. How can I use the Inventory Management CLI to check reservations per stock?
Magento 2 inventory management provides powerful CLI tools. To check reservations per stock, you can use the inventory:reservation:list-inconsistencies
command. This command shows where reservation enters inconsistencies for each stock. For example:
bin/magento inventory:reservation:list-inconsistencies
This command is part of the inventory management CLI reference. It helps you identify and resolve reservation issues across different stocks.
2. How do Source Selection algorithms interact with reservations?
The Source Selection algorithm and reservations work together to manage product inventory effectively. When an order is placed, the Source Priority algorithm determines which source(s) to use based on factors. Examples include stock amount and proximity. Reservations then hold the inventory at the selected source(s). To clear these holds:
- First, check the current reservation status:
bin/magento inventory:reservation:list-inconsistencies
- If needed, clear the reservations for a specific product:
bin/magento inventory:reservation:create-compensations
It helps maintain accurate stock amounts across your inventory sources. You should avoid discrepancies in your product inventory.
3. How do reservations affect salable quantity?
Reservations produced in a single order can affect your salable quantity. The system will issue a reservation in response to various events. Examples include "adding items to cart" or "placing an order". These reservations reduce the salable quantity to prevent overselling. During invoicing, the system handles reservations per source. It ensures accurate inventory tracking across multiple warehouses. As orders are processed and shipped, Magento automatically updates your salable quantity. It reflects both the reservations and actual inventory changes.
4. How does Magento 2 handle inventory reservations from order placement through shipment?
Magento 2 manages inventory reservations dynamically throughout the order lifecycle. In response to a new order, the system immediately creates a reservation. This reservation considers the shipping destination address and source locations. It determines the best fulfillment strategy to secure the inventory. As the order progresses, order placement & shipment events trigger updates to the reservation. The scope of an order, including its items and quantities, is carefully tracked. When the order ships, the order should resolve the initial reservation. It should be converted into a permanent inventory reduction.
5. What challenges arise when changing configurations or handling large order volumes?
Managing inventory reservations in the Magento 2 platform can become complex. Problems may especially arise when dealing with configuration changes or high-order volumes. An initial reservation that deducts inventory may lead to issues. It is if the system enters too many reservation compensations. It causes discrepancies in your stock levels. You might encounter inconsistencies in how the system handles reservations for these orders. It occurs when you later enable the manage stock configuration. It can be for a website after some orders have already been placed. The stock for a website might show unexpected levels. The system attempts to reconcile the new configuration with existing orders and reservations.
6. How does Magento 2 manage reservations across multiple stocks and sources?
Magento 2's inventory reservation system works seamlessly across multiple stocks and sources. When an initial reservation enters for the initial stock, the system considers availability across all linked sources. In more complex setups, Magento 2 uses Google Maps Platform services. It uses this to calculate the distance between shipping destinations and inventory sources. It helps to optimize source selection for order fulfillment. However, in some cases, the system might incur too much reservation compensation. It can lead to discrepancies in stock levels. Some orders will already be in process. The system strives to maintain accurate stock across all sources and stocks. The interplay between distance-based source selection & multiple stocks can lead to unexpected results.
Summary
Magento 2 inventory reservation ensures your inventory remains up to date across all sources. This feature helps merchants:
- Track available inventory and prevent overselling.
- Handle reservations for products across multiple sources.
- Manage reservations and resolve inconsistencies.
- Optimize your stock flow and ensure customer satisfaction.
- Maintain smooth order flow and accurate stock levels.
Consider Magento hosting plans to maintain smooth inventory flow from the moment an order is placed to the shipment.