Using Dynamic vs Static Product Pricing
在Product Page,ATG 支持兩種定價模式,即動態和靜態定價方式:
靜態定價工作流程:
catalog每一個item都有一個listPrice 屬性,然後你可以在shopping cart,order,tax使用它作爲基本價格進行計算,你也可以給每一個item一個固定的價格salePrice ,在product page 你可以直接使用。
<dsp:droplet name="/atg/dynamo/droplet/Switch">
<dsp:param param="sku.onSale" name="value"/>
<dsp:oparam name="false">
List price of <dsp:valueof param="sku.listPrice" converter="currency"/>
</dsp:oparam>
<dsp:oparam name="true">
List price of <dsp:valueof param="sku.listPrice" converter="currency"/>
on sale for <dsp:valueof param="sku.salePrice" converter="currency"/>!
</dsp:oparam>
</dsp:droplet>
動態定價的工作方式:
Commerce會使用一下的機構對每一種類型進行定價:
1 Pricing Engine
2 One or more calculators
3 a helper method in the qualifier service
4 an item-descriptor in the promotions repository
How Price Services Generate the Prices?
1 首先會給予2個基本的組件:price engine and price caculators
2 價格引擎做的事:
取得站點訪問者的有效的promotions
決定採用哪一個價格計算器計算價格
採用正確的順序調用計算器
3 價格計算器主要負責:
查詢價格
使用價格引擎得到的信息,然後決定價格
4 在定價以前,以下的一些步驟會發生:
- 價格引擎會加載全局的promotions,使用globalPromotionsQuery 屬性去查詢
- 用戶session 開始的時候,會創建PriceModelHolder實例,然後調用價格引擎的getPricingModes();
- pricing engine getPricingModels() method gets any promotions listed in the activePromotions
property of the current customer’s profile, 並且和全局的epromotions進行一個merge - PricingModelHolder 將會定期更新全局的和active promotions
當用戶添加一個item到shopping cart 會發生什麼?
1 業務邏輯層調用價格引擎
2 定價操作然後調用PricingTools ,接着得到PricingModelHolder
3 PricingTools從PricingModelHolder 得到promotions,然後調用價格引擎的priceItems方法
4 價格引擎接着應用它配置的precalculators,不同種類的價格引擎會調用不同precalculators,比如OrderPricingEngineImpl calls OrderPricingCalculators and the TaxPricingEngineImpl calls
TaxPricingCalculators.
5 價格引擎接着應用它配置的postcalculators
6 價格引擎最後返回更新的priceInfo 對象