About OrderGroup

Hi Guys

I am directly working with Basket object that is, adding forms into the basket and adding lineitems into the forms and saving it. its working fine ..

But now i want to create a wish list(Favorite List) and order template,

According to some blogs, OrderGroup is used as a template and wishlist and later that can be converted to basket and purchaseorder. How to create an basket from the OrderGroup . it will be very helpful for me..

But there is no option in OrderGroup class to save as basket.. What is the next step to proceed..

and alos what is core differcence between OrderGroup and Basket . then how the basket was diffrencted from the OrderGroup.. Please provide any link to study about more...




Answer this question

About OrderGroup

  • Furrukh Baig

    Prabagarane,

    The Basket class actually *is* an OrderGroup, so you work with them very much in the same way.

    The fundamental difference, as I see it, is the manner in which the object is created. You've no doubt noticed that the Basket class has no public constructor to work with, and you in fact need to create it using the OrderContext.GetBasket method. On the other hand, the OrderGroup class does expose a public constructor, so that you can instantiate an OrderGroup object without accessing the Context objects.

    If you're wondering how to add an OrderGroup to a Basket, I beleive the method you're looking for is here: http://msdn2.microsoft.com/en-us/library/ms867658.aspx

    As per the nature of your question, I don't know which Blog you're referencing, but I really encourage you to use named baskets instead of OrderGroup and OrderTemplate in CS2007. What you're suggesting was a perfectly acceptable approach in older versions of Commerce Server, but named baskets gives you a far more intuitive approach for working with multiple lists of orders.

    Specifically, why bother with code like this:

    //Grab the current user's basket
    Basket basket = CommerceContext.Current.OrderSystem.GetBasket(CommerceContext.Current.UserID);
    //Create a "wish list"
    OrderGroup ordergroup = New OrderGroup();
    //Add "wish list" to current basket
    basket.Add(ordergroup);

    When you can just use:

    Basket basket = CommerceContext.Current.OrderSystem.GetBasket(CommerceContext.Current.UserID, "Wish List");

    It's just so much easier this way, and you can reuse the same design patterns for both the wish list and the active basket instead of designing one path that works with baskets and one path that works with wish lists.



  • dagjo

    Praba,

    You're going to create what sounds like up to three baskets for each user. Keep in mind that regardless of how you were to implement this, you're looking at three distinct order records located *somewhere* in the database, so I don't think you should be concerned about this, even though all three records are living in the same table.

    Keep in mind that the query for pulling back baskets (named or otherwise) is still on an indexed column in the table, so this probably isn't the first thing I'd worry about performance tuning.



  • Jiajia

    Hi Joe

    I am going this way, that is - Create basket's for all those things..

    If users enters the name for the basket and saved it. so - at the time i concotinate the user Guid and the name of the basket.

    So we think about performace.. may i rite...



  • jordan V

    Hi Joe

    shall we create Three basket for an user and create as many orders in a basket (wishlist , ordertemplate, cart) . So occording that -

    basket it three and orders is many in particular basket.. can i do like this. is it rite so no need to create many baskets .. only order's are increasing....may i rite..



  • MarkDu

    Hi Joe

    Thanks for the Answer,its very usefull for me. ok, i am going this way . one doubt joe,

    if we increasing the basket for an user, that is - i am going to create many ordet template basket and wishlist and one active cart etc.

    so many baskets are created for an single user, Like wise there are so many basket's objects are created for several user, So is there any chance to affect the performance of the applicaton. how about the database marshalled data...



  • Vulcanoro

    Praba,

    I'm not quite sure that I understand what you mean by multiple orders in a basket. The basket class exposes an API command SaveAsOrder, which actually moves the basket from the basket table to the purchaseorder, lineitem, shipment, orderformheader tables. At this point, you can no longer work with this as a Basket object, and you now work with it as a PurchaseOrder object.

    I'm guessing you assumed that the OrderForm object was in fact a distinct order, which is not the case. A basket can contain multiple orderforms, but there is no method to save an orderform as an order.

    Have another look at the object model: http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnanchor/html/commerceserver.asp

    As you can see, distinct "orders" are encapsulated by PurchaseOrder, Basket, and OrderTemplate. The product team is now discouraging new developers from using the OrderTemplate, meaning you need to use the Basket class for each in-process order (be it a wish list, a recurring order, or the current order).



  • About OrderGroup