Try our conversational search powered by Generative AI!

Workflow error with package in cart

Vote:
 

Hi,

I believe we just struck a bug when trying to purchase a package using Commerce 11.2.6

First of all, if inventory is not tracked for an sku should the CheckInventoryActivity be run at all?

Now for the error, in GetNewLineItemQty there is a call to OrderGroupActivityBase.InventoryTrackingEnabled to check if inventory is tracked. That function assumes that the sku is of type VariationContent. PackageContent is not inheriting VariationContent so we get the exception below.

I believe Package is to be interpreted as an sku and should be buyable, correct? Or have we setup the packages in the wrong way?

By the way, what happened to the downloadable zip containing the episerver.commerce.website source code? I don't seem to find it anymore.

2017-11-15 22:13:09,191 [10] ERROR EPiServer.Global: 1.2.5 Unhandled exception in ASP.NET
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ApplicationException: Workflow generated an exception, please look at the previous error for more details. ---> EPiServer.Core.TypeMismatchException: Content with id '71494__CatalogContent' is of type 'Castle.Proxies.MultiPackageProxy' which does not inherit required type 'EPiServer.Commerce.Catalog.ContentTypes.VariationContent'
at EPiServer.Core.Internal.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)
at Mediachase.Commerce.Workflow.Activities.OrderGroupActivityBase.InventoryTrackingEnabled(LineItem lineItem)
at Mediachase.Commerce.Workflow.Activities.OrderGroupActivityBase.GetNewLineItemQty(LineItem lineItem, List`1 changeQtyReason, Shipment shipment)
at Mediachase.Commerce.Workflow.Activities.CheckInventoryActivity.AdjustInventory(LineItem lineItem, Shipment shipment, List`1 deletedLineItems)
at Mediachase.Commerce.Workflow.Activities.CheckInventoryActivity.ValidateItems()
at Mediachase.Commerce.Workflow.Activities.CheckInventoryActivity.Execute(ActivityExecutionContext executionContext)
at Mediachase.Commerce.WorkflowCompatibility.Activity.Execute()
at Mediachase.Commerce.Engine.ActivityFlowRunner.<>c__DisplayClass15_0`1.b__0()
at Mediachase.Commerce.Engine.ActivityFlowRunner.Execute()
at Mediachase.Commerce.Engine.ActivityFlowRunner.Execute()
at Mediachase.Commerce.Engine.ExecutionManager.ExecuteActivityFlow(String name, ActivityFlowContext context)

#185349
Nov 15, 2017 22:57
Vote:
 

Sounds like a bug in our side, and this one is probably related to me. I will file a bug report and work on it asap. Thanks for letting us know.

Regarding the source code, you should be able to download from here :

https://world.episerver.com/download2/, no?

#185350
Nov 15, 2017 23:20
Vote:
 

Thanks, was looking for it a wekk or two back but then the samples wheren't there. Or maybe I was blind.

Thanks for digging into it asap! I've been trying to find a workaround as it's affecting a production site but haven't found any yet. Now I at least have the source code so we can patch it up :)

#185351
Nov 15, 2017 23:27
Vote:
 

No you were not blind. We realized the download section was in wrong place and corrected it recently. 

#185352
Nov 16, 2017 7:01
Vote:
 

Just noticed that one can replace a flow without dragging in the full workflow project. Howeverä I canät get it to work.

I've created my flow override ride as

[ActivityFlowConfiguration(Name = OrderGroupWorkflowManager.CartValidateWorkflowName, Priority = 1)]
    public class CartValidateActivityFlow : ActivityFlow
    {
        /// <inheritdoc />
        public override ActivityFlowRunner Configure(ActivityFlowRunner activityFlow)
        {
            return
                activityFlow
                    .Do<ValidateLineItemsActivity>()
                    .Do<GetFulfillmentWarehouseActivity>()
                    //.If(ShouldCheckInstoreInventory)
                    //    .Do<CheckInstoreInventoryActivity>()
                    //.Else()
                    //    .Do<CheckInventoryActivityMod>()
                    //.EndIf()
                    .Do<RemoveDiscountsActivity>()
                    .Do<CalculateDiscountsActivity>()
                    .Do<UpdateTotalsActivity>();
        }
    }

But it's still the original CartValidate flow that runs. I've read the documentation a few times now and cant figure out if I've missed anything. Should this be sufficient?

#185357
Nov 16, 2017 12:51
Vote:
 

If you downloaded the project and build it, changing InventoryTrackingEnabled method in OrderGroupActivityBase should fix the problem

Snippet

protected bool InventoryTrackingEnabled(LineItem lineItem)
{
    var sku = GetEntryContentForLineItem<EntryContentBase>(lineItem) as IStockPlacement;
    return sku != null && sku.TrackInventory;
}
#185359
Nov 16, 2017 13:24
Vote:
 

Found out why. We didn't have the WorkflowsVNext feature in ecf.app.config at all, and it got automatically added by Commerce 11.2.0 with state Disabled.

Apparently you can not override a flow as above if WorkflowsVNext is disabled :)

#185360
Nov 16, 2017 13:30
Vote:
 

Thanks but I don't want to use the entire project. It was easier this way since the customer don't have any tracked inventory at all anyway :)

Prod env patched, case closed :) 

Thanks Quan for your fast responses.

#185362
Nov 16, 2017 13:42
Vote:
 

And thank you for letting us know. The bug fix is in review and will be released in an upcoming version - probably 11.5.0

#185363
Nov 16, 2017 14:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.