This discussion is archived
14 Replies Latest reply: Oct 10, 2012 8:52 PM by 333 RSS

How the PricingModelHolder instance is created when session starts

333 Newbie
Currently Being Moderated
At the start of the customer session, a PricingModelHolder instance is created.

How it will be created.





regards
shya
  • 1. Re: How the PricingModelHolder instance is created when session starts
    Nitin Khare Expert
    Currently Being Moderated
    PricingModelHolder is used as session scoped component /atg/commerce/pricing/UserPricingModels. You can find following dependency declared to PricingModelHolder in the ProfileFormHandler (class: CommerceProfileFormHandler) through DCS config layer:

    userPricingModels=/atg/commerce/pricing/UserPricingModels

    Its initialization is done through postLoginUser() so when customer logs in, UserPricingModels component is initialized by querying each pricing engine (item, order, tax and shipping) to load the promotions that the user should have. If during the life cycle of the session, any new promotion gets applied to the user the initialization method can be called again to have updated session cache of promotions.
  • 2. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi nitin

    as you said, initialization is done through postLoginUser() so when customer logs in.
    then how UserPricingModels component initialized for anonymous user.



    regards
    shya
  • 3. Re: How the PricingModelHolder instance is created when session starts
    Nitin Khare Expert
    Currently Being Moderated
    Actually UserPricingModels component is created and started whenever the user session starts. It can provide you a merged list of global and active promotions for the each pricing engine for transient and persistent user. There is a initializePricingModels() method in PricingModelHolder which is called when the UserPricingModels starts. When I said - initialization done through postLoginUser(), I actually mean to say invocation of this initializePricingModels() method. Internally this initializePricingModels() does nothing but querying each pricing engine - item, order, tax and shipping to load the promotions. After user logs in, PricingModelHolder is re-initialized by invocation of initializePricingModels() through postLoginUser() so that all the promotions that the user might have accumulated during previous sessions can also be cached.
  • 4. Re: How the PricingModelHolder instance is created when session starts
    Nooruddin Shaik Expert
    Currently Being Moderated
    The pricingmodelholder is initialzed from the profile activePromotions property.
    For anonymous user as there is no profile in DB, nothing is loaded.

    But as the user qualifies the promotions/promotions are given to him, the promotions are added to this list.

    Peace
    Shaik
  • 5. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi ,
    what is the uses calculatorTypeCalculators property in pricingEngine (ex-ItemPricingEngine)




    Regards
    shya
  • 6. Re: How the PricingModelHolder instance is created when session starts
    karthik chopperla Pro
    Currently Being Moderated
    These are just type of discount calculators to be used for standard pricing, bulk pricing, tiered pricing

    http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGCommProgGuide/html/s1003bulkitemdiscountcalculator01.html

    If you are using standard pricing with items, all your OOTB promotions use Item/Order/ShippingDiscountCalculator.

    -karthik
  • 7. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi,
    what is the uses of closenessQualifier




    regards
    shya
  • 8. Re: How the PricingModelHolder instance is created when session starts
    karthik chopperla Pro
    Currently Being Moderated
    http://docs.oracle.com/cd/E23507_01/Platform.20073/ATGCommStoreGuide/html/s0504settingupupsellingincentives01.html

    -karthik
  • 9. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi,
    what is the uses of --->/atg/commerce/pricing/GlobalPromotionsDate component
  • 10. Re: How the PricingModelHolder instance is created when session starts
    Nitin Khare Expert
    Currently Being Moderated
    All global promotions are retrieved from the database and loaded during server startup. This collection of global promotions is periodically refreshed also so that any new global promotions can be loaded as well. GlobalPromotionsDate component is used for the purpose of refreshing global promotions and it uses a scheduler for this purpose. GlobalPromotionsDate component actually resets the time through scheduler which is used in the query to find available global promotions.
  • 11. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi,

    difference between the below methods :

    public abstract ItemPriceInfo priceItem(CommerceItem commerceitem, Collection collection, Locale locale, RepositoryItem repositoryitem, Map map)
    throws PricingException;

    public abstract List priceEachItem(List list, Collection collection, Locale locale, RepositoryItem repositoryitem, Map map)
    throws PricingException;

    public abstract List priceItems(List list, Collection collection, Locale locale, RepositoryItem repositoryitem, Order order, Map map)
    throws PricingException;

    with clear explanation.

    regards
    shya
  • 12. Re: How the PricingModelHolder instance is created when session starts
    Nitin Khare Expert
    Currently Being Moderated
    If you are showing only static price you can retrieve and display the list/sale price directly from the SKU object whereas these ItemPricingEngine methods used to dynamically price a single CommerceItem or a list of CommerceItems by taking the promotions into account. Let's look at each of these methods in detail.
    public abstract ItemPriceInfo priceItem(CommerceItem commerceitem, Collection collection, Locale locale, RepositoryItem repositoryitem, Map map)
             throws PricingException;
    The method parameters are usually common input for various pricing operations and together they constitute a pricing context. These are:
    commerceitem - The single CommerceItem which is to price
    collection - Collection of RepositoryItems representing PricingModels (promotions)
    locale - Locale to use for pricing
    repositoryitem - RepositoryItem for the customer's profile
    map - Map of extra parameters to be used in the pricing and can be null

    The priceItem() method prices a single CommerceItem and returns ItemPriceInfo object for the passed item. It applies any PricingModels (promotions) that are passed via the second parameter if they are qualified. The single item that is passed in is the only one which is used to qualify the requirements of a promotion. In other words, promotions that relate to only one item are applied and not those which are applicable at Order or Shipping level. E.g. if the CommerceItem passed as parameter is for "1 quantity of A" and there is a promotion for "Buy 2 or more of A, get one free" the promotion would not take effect. This method is usually used for displaying item prices when a customer is browsing the catalog.
     
    public abstract List priceEachItem(List list, Collection collection, Locale locale, RepositoryItem repositoryitem, Map map)
             throws PricingException;
    Here method arguments are:
    List - The list of commerce items to price (individually)
    Rest of the arguments are same as above.

    The priceEachItem method batch processes all the input CommerceItems that are passed into it through the list and price them as single item. It returns a List of ItemPriceInfo objects representing the price quotes for each input item.
    public abstract List priceItems(List list, Collection collection, Locale locale, RepositoryItem repositoryitem, Order order, Map map)
             throws PricingException;
    Method arguments here are:
    List - The list of commerce items to price (together in same pricing context)
    Rest of the arguments are same as previous one.

    priceItems method prices all input CommerceItems in the same pricing context and returns list of ItemPriceInfo objects representing the price quotes for the input items. Continuing with the same example, the customer now adds 2 quantity more of item A in the shopping cart so cart now has "3 quantity of A". While the customer is just browsing the catalog, the "Buy 2 or more of A, get one free" promotion is not factored in when displaying prices. And therefore when the customer adds item "A" to the shopping cart, the price shown will still be full price for all the items. However, when the customer subsequently goes on to display the contents of cart, the promotion takes effect and shows that one "A" is free.
  • 13. Re: How the PricingModelHolder instance is created when session starts
    karthik chopperla Pro
    Currently Being Moderated
    Calculators extending this abstract class will have these methods implemented. They are meant to facilitate while pricing based on the context. If multiple items are to be priced, then priceItems will call priceItem iand that internally calls priceEachItem. If only single item is to be calculated, priceItem can be called.

    -karthik
  • 14. Re: How the PricingModelHolder instance is created when session starts
    333 Newbie
    Currently Being Moderated
    hi karthik,

    can you please explain clearly the below line which you post:

    If multiple items are to be priced, then priceItems will call priceItem iand that internally calls priceEachItem.

    where its internally calls priceEachItem.


    regards
    shya

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points