We are experiencing similar issue with Inventory. Its not returning accurate number and that results in overselling products.
our investigation is in very early stage. This issue happens when there is sudden jump in customer's traffic and i believe this happen when concurrent users tries to checkout. I was thinking to disable cache for catalog but i believe Eiserver do not cache inventory.
Hi Stephen
It is probably not the root cause of your issue, but you could call _inventoryProcessor.AdjustInventoryOrRemoveLineItem
on the cart, before saving it as a purchase order. If it returns any validation issues you can continue with the adjusted cart, or you can abort the process and show an error message.
And when your job runs to change the order status, do you also commit the inventory reservations (by calling _inventoryProcessor.AdjustInventoryOrRemoveLineItem
again)? I would put it between setting the new order status and saving the purchase order object.
I also get this intermittent inventory allocation issue in Commerce v13.24. It's very intermittent and we could not replicate on other environments
The call to _inventoryProcessor.AdjustInventoryOrRemoveLineItem
is in between payment and save cart into purchase order. There weren't any errors returned during the AdjustInventory call.
For a particular SKU, I can see the [dbo].[LineItems] table values for the two orders as below (not even consecutive orders):
After the last order done at 4:27AM, the stock has decreased to 393 (in reality, it should have been 392).
Will there be any other possible cause(s) to this issue?
The stakeholders are a bit concerned that this issue may potentially happen for limited one-stock only items and that they don't want to oversell.
There are a few examples here of sporadic issues with Inventory allocation causing overselling for customers at least up to Commerce v13.24.
Maybe somebody at Optimizely can let us know if this is recorded as a known issue?
Curious if you run validate cart before processing any transaction? Validate cart should check following:
For all the above we have existing Optimizely API to trigger validation. In the case of inventory... it looks something like this
cart.UpdateInventoryOrRemoveLineItems((item, issue) => AddValidationIssues(validationIssues, item, issue), _inventoryProcessor);
There is something else we always follow in our order processing:
Before processing the payment on a cart, we always reserve inventory so it is not used by someone else during the order creation process. We first mark the inventory InProgress. Following line tries to reserve inventory and will not allow to process if no inventory available.
this._inventoryProcessor.AdjustInventoryOrRemoveLineItem(cart.GetFirstShipment(), OrderStatus.InProgress, (item, issue) => { });
Do not forget to clear the reservation of inventory using Cancelled or Completed based on the events.
~ Sujit
We having an issue relating to inventory levels and behaviour that results in the overselling items that should have 0 inventory and be out of stock.
The issue is intermittent and happening a number of times every day.
We are also unable to replicate the issue locally in development nor in internal test environment so appears to be isolated to the DXC live environment.
Has anyone else experienced a similar issues ?
Having added some logging to try understand what is happening, we can see what appears to be happening is inventory is returning to it’s previous level a short period of time after hitting zero, an example from our logs:
Order placed for last item in stock:
Next order placed on the same say when item is out of stock:
Note these log entries are from the same application server so we do not believe this is a load balancing issue
The following code snippets detail the processing of orders within the solution:
....Following successful payment
// Save cart as purchase order with an initial status of 'On Hold'
var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
// Load saved purchase order asset status
var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(orderReference.OrderGroupId);
purchaseOrder.OrderStatus = OrderStatus.InProgress;
purchaseOrder.PricesIncludeTax = true;
// Ensure shipment has warehouse code and inventory status
var shipment = purchaseOrder.GetFirstShipment();
shipment.WarehouseCode = _warehouseSettingsProvider.DefaultWarehouseCode;
shipment.OrderShipmentStatus = OrderShipmentStatus.InventoryAssigned;
// Save purchase order changes and remove the cart
_orderRepository.Save(purchaseOrder);
_orderRepository.Delete(cart.OrderLink);
// Run inventory activity
_inventoryProcessor.AdjustInventoryOrRemoveLineItem(shipment, purchaseOrder.OrderStatus, (item, issue) => validationIssues.Add(item, issue));
_orderRepository.Save(purchaseOrder);
... Continue with displaying order confirmation
4 times per day an order status import occurs which updates the order status to completed and shipping status to shipped:
var purchaseOrder = _purchaseOrderRepository.Load(trackingNumber);
if (purchaseOrder != null)
{
order.Id = purchaseOrder.OrderLink.OrderGroupId;
var shipment = purchaseOrder.GetFirstShipment();
shipment.ShipmentTrackingNumber = courierTrackingNumber;
shipment.OrderShipmentStatus = OrderShipmentStatus.Shipped;
purchaseOrder.OrderStatus = OrderStatus.Completed;
_orderRepository.Save(purchaseOrder);
_mailService.SendDispatchEmail(emailAddress, order);
}
Has anyone experienced any similar issues ?
Is there anything in the code snippets you can see that should be executed differently, or any steps missing ?
The project is using CMS v11.11.2, Commerce v12.17.2
Thanks,
Stephen