One of the big challenges when running a large e-commerce operation is ensuring that you have the right products in stock and for sales all of the time. If you have stock for an item, it should be available to your customers for purchase. Crucially, if you don’t, then it should either be taken offsale or customer expectations set. Few things are likely to keep your customer service phone lines ringing more than when you start to miss promised delivery dates for orders.
In a Magento environment, products will be taken off sale automatically if the inventory level for that product is set to zero. The challenge is to ensure that this inventory level is accurate.
Unfortunately, this is less easy to achieve in practice than it sounds.
Magento inventory update efficiency
If you are only running a few SKUs, one of your team members may have the responsibility of manually removing products from sale if they go out of stock.
For large online retailers carrying tens of thousands of SKUs, this simply isn’t feasible. What’s required is a timely and accurate update of the inventory level based on an accurate stock position provided from your warehouse. For this you will need a warehouse management system (WMS) which integrates seamlessly with Magento.
Magento provides a built-in API that allows you to update inventory for a product (using the
catalogInventoryStockItemUpdateweb services call in Magento 1, and
catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest in Magento 2).
The problem with the inventory update is that it only supports the update of one inventory record at a time. If Magento is under heavy load – and most Magento store owners will have experienced this – then inventory updates can take a long time to process. The result may be a delay in making available products for which new stock has been received, and a delay in removing products from sale that have sold out.
At Realtime Despatch we have gone to a lot of effort to make sure that inventory updates are efficient. As well as supporting the native Magento API, we also provide an open source module with advanced inventory update support. Inventory updates are sent in bulk into Magento and queued there. The actual processing of inventory updates is then done efficiently, with various failure tolerance mechanisms built in.
The unsent orders problem
Even if we can overcome the challenge of efficient inventory updates, another awaits. A naively implemented inventory update mechanism will not take into account all of the orders received, and will tend to overstate the available inventory.
The inventory number that is reported from the WMS typically involves the following:
- The total quantity in the warehouse for the product
- Less any stock that is not usable (e.g. in quarantine)
- Less any stock that is allocated to orders that are known to the WMS
The problem is that there may be orders that have been received, or are being received, that the WMS does not know about when the calculation is made.
These may include orders that have been received into Magento but not yet sent to the WMS. They will also include orders that are currently in shopping carts, but have not yet been placed.
When using the built-in Magento API, it is not possible for the WMS to account for these orders in a precise way because by definition the WMS has no visibility of orders not yet placed or received. A workaround is to use a threshold inventory level, say five, below which a value of zero is reported. In this case, as long as there are no more than five unsent orders, and inventory updates are applied efficiently, products will invariably be taken offsale before they go out of stock.
The above provides a basic solution to the problem, but is imperfect in a several ways. Firstly, a decision needs to be taken on the out of stock quantity threshold, possibly even at a product level. Secondly, there will inevitably be situations where products are taken out of stock prematurely. There may be only a few items left, but this will result in some lost revenue.
A more refined approach
With Realtime Despatch’s OrderFlow Magento module in place, a more refined approach to this problem is possible. When an inventory record is sent to Magento, the entry will also include a timestamp identifying the most recently received order for that product.
The OrderFlow Magento module is then able to use the Magento API internally to determine the number of items for orders have been placed since this time. It can even take into account orders recently added to customers’ shopping carts but not yet placed. Using these pieces of information, the Magento module is able to adjust the inventory record in an accurate way, helping to avoid unnecessary out of stocks, but at the same time ensuring that available stock can still be sold.
Why not get in touch to find out more about our Magento module?
By Phil Zoio, Director & CTO, Realtime Despatch Software Ltd.