Try our conversational search powered by Generative AI!

Inventory status set to null will result in CartValidation workflow error

Found in

Commerce 8.13.2

Created

Jun 17, 2015

Updated

Jun 26, 2015

Area

Falcon/Commerce

State

Closed, Fixed and Tested


Steps to reproduce

This was reproduced using Commerce Manager add-to-cart instead of using the Commerce sample site front-end (I couldn't reproduce using checkout on the front-end)


Steps to reproduce

  1. Create a sku with inventory tracking disabled.
  2. This may not be relevant to reproducing the issue, but under Pricing tab, set Min Quantity: 0, Max Quantity: 1000, and add a price to the Default Market
  3. Under Warehouse Inventory tab, set In stock value to something like 1999.
  4. Save the sku
  5. Go to Order Management, create new cart, and then add that line item to cart. Then go to More Actions > Convert to Purchase Order. You will get an error. This is what gets logged:
System.ArgumentNullException: Value cannot be null.
Parameter name: request
   at Mediachase.Commerce.InventoryService.InventoryServiceProvider.Request(InventoryRequest request)
   at Mediachase.Commerce.Workflow.Activities.Cart.AdjustInventoryActivity.RequestInventory(OrderForm orderForm, Shipment shipment, LineItem lineItem)
   at Mediachase.Commerce.Workflow.Activities.Cart.AdjustInventoryActivity.Execute(ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
   at System.Workflow.Runtime.Scheduler.Run()
System.ArgumentNullException: Value cannot be null.
Parameter name: request
   at Mediachase.Commerce.InventoryService.InventoryServiceProvider.Request(InventoryRequest request)
   at Mediachase.Commerce.Workflow.Activities.Cart.AdjustInventoryActivity.RequestInventory(OrderForm orderForm, Shipment shipment, LineItem lineItem)
   at Mediachase.Commerce.Workflow.Activities.Cart.AdjustInventoryActivity.Execute(ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
   at System.Workflow.Runtime.Scheduler.Run()

You should be able set a sku to disabled inventory, so this is likely a bug. This issue seems due to the code in AdjustInventoryActivity for RequestInventory() method (reflecting NuGet Mediachase.Commerce.Workflow.dll).

RequestInventory() seems to be different in the source code version found in World, which is:

 private void RequestInventory(OrderForm orderForm, Shipment shipment, LineItem lineItem)
        {
            var lineItemIndex = orderForm.LineItems.IndexOf(lineItem);

            var request = AdjustStockItemQuantity(shipment, lineItem);

            if (request != null)
            {
                InventoryResponse response = _inventoryService.Service.Request(request);
                if (response.IsSuccess)
                {
                    lineItem.IsInventoryAllocated = true;

                    // Store operation keys to Shipment for each line item, to use later for complete request
                    var existedIndex = shipment.OperationKeysMap.ContainsKey(lineItemIndex);
                    var operationKeys = response.Items.Select(c => c.OperationKey);
                    if (!existedIndex)
                    {
                        shipment.AddInventoryOperationKey(lineItemIndex, operationKeys);
                    }
                    else
                    {
                        shipment.InsertOperationKeys(lineItemIndex, operationKeys);
                    }

                }
            }
        }


Expected: Able to purchase skus with inventory disabled (examples included digital downloads which have no physical inventory)

Actual: Workflow error