28 Mar 2010

Line Item Grouping

as you know in Commerce Server 2009 API we cannot specify if a specific item should be grouped or not when added to the basket....

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);

}
}

1 comment:

  1. Man, you saved my day! Thank you very much for sharing this.

    Cheers
    Alex

    ReplyDelete