31 March 2022

Real time stock issues in Magento

We’ve worked on several customer projects that required real time stock information in Magento. With the Tinx-IT Magento E-commerce connector, it is possible to send and receive stock data between Magento and Business Central (BC). When a stock mutation takes place within BC, it sets off a trigger to send the new stock value to Magento. This is possible by sending a stock update to the webshop as soon as a specific formula is triggered: stock minus quantity in sales order.

Inventory reservation

The challenge is that if a customer uses MSI (Multi-Source Inventory) in Magento, the default stock update formula stops working. In Magento version 2.3.3, quantity is no longer modified on the webshop side after placing an order. MSI works as follows: it adds a different field, that’s called “inventory reservation”

Incorrect stock levels

When an order is placed on the webshop, the“salable quantity” field of the SKU (Stock Keeping Unit) will be changed, but the “quantity” field doesn’t get a similar update on its own. Magento adds a record to the inventory reservation table. However, only when a shipment or refund has been created on the webshop, Magento will add a new record to the inventory reservation table that will change the “quantity” field.

The result of this change? Stock level problems will occur as soon as a web order comes into BC and a stock update is triggered towards Magento. The value “quantity” minus “quantity in the sales order” is sent back to Magento. At this point, BC “understands” that it has a certain salable quantity left and it wants to update Magento with these values. However, as a shipment (or refund) for this transaction has not (yet) been made in BC, the connector will not be able to create a shipment for it in Magento prior to sending the newest inventory levels. This causes different values between “quantity” and “salable quantity”.

Quantity not available


In the example above, the stock level on the frontend displays “In stock” as the quantity is 112. Nevertheless, when you try to order this item, it will return an error as the “salable quantity” is 0.


To resolve this issue, it is important to determine if the order originated from Magento, or if the order is coming from elsewhere (e-mail, phone, POS-orders). If the order initially comes from Magento, a refund or shipment is needed to finalize the inventory levels in relation to the order. If an order comes from a different source, the stock reservation process in Magento needs to be disabled in order to not interfere with the correct inventory levels.

We can do this through a special module that disables the entry in the stock reservation table and changes the “quantity” and “salable quantity” with each new order. Additionally, this module also solves the stock reservation issues for orders originating outside the webshop (e-mail, phone, POS orders). As a result, a shipment or refund is no longer necessary.
For the record, all other functionalities within MSI will keep working.