what we can do, we can specify a global setting (RollUp) in the channel configuration for the BasketLineItemProcessor to say the default behavior when we add an item to the basket.
what about if we have a custom business logic for line item grouping and we need more control???
simple, just make a new Class that Inherits from BasketLineItemProcessor, override the addToBasket method and impement the custom Business logic to set the ShouldRollup property
public class CUSTOMBasketLineItemProcessor : BasketLineItemsProcessor
{
protected override void CreateRelatedItem(Microsoft.Commerce.Contracts.Messages.CommerceCreateRelatedItem createRelatedItemOperation)
{
CommerceEntity model = createRelatedItemOperation.GetModel("LineItem");
//Read model.Properties and set ShouldRollup = true; or ShouldRollup = false;
base.CreateRelatedItem(createRelatedItemOperation);
}
}
Man, you saved my day! Thank you very much for sharing this.
ReplyDeleteCheers
Alex