Saturday, January 14, 2012

ATG : Extending Pricing Engine


ATG Commerce provides several preconfigured pricing engines (see Default Pricing Engines). You can
extend these engines to fit your sites’ requirements, and you can also create new pricing engines if
necessary.

Extending a Pricing Engine 


You can extend one or more of the pricing engine implementations to provide new pricing functionality.
For example, you can extend ItemPricingEngineImpl to create an algorithm that prices a set of items
differently from the current implementation of priceEachItem. You could create an algorithm that
applies promotions in a random order rather than in order of ascending precedence.
Because each implementation of the PricingEngine interface extends the PricingEngineService
class, you can extend one or all of the implementations to alter the behavior of a method of
PricingEngineService. For example, you could implement the expirePromotion method to send a
JMS event enabling the creation of scenarios related to unused and expired promotions. After you
complete your extensions, configure the corresponding pricing engine component to use the class. (For
more information, see the description of PricingEngineService.)
Each engine can also be extended to leverage existing code. For example, you can extend the pricing
engine to determine global promotions using a Personify or NetPerceptions integration. The
ItemPricingEngine could be extended to get its global promotions from the integration.
The relevant interfaces are:

· atg.commerce.pricing.ItemPricingEngine
· atg.commerce.pricing.TaxPricingEngine
· atg.commerce.pricing.ShippingPricingEngine
· atg.commerce.pricing.OrderPricingEngine
· atg.commerce.pricing.ItemDiscountCalculator
· atg.commerce.pricing.OrderDiscountCalculator
· atg.commerce.pricing.ShippingDiscountCalculator

The properties of a promotion repository item are in
atg.commerce.pricing.PricingModelProperties.
The Qualifier class that holds helper methods is atg.commerce.pricing.Qualifier.
Creating a New Pricing Engine
In the following example, you want to create a new pricing engine that prices handling costs separately
from shipping. You create a HandlingPricingEngine that acts independently of the
ShippingPricingEngine.

1. Create an interface called HandlingPricingEngine that extends PricingEngine.

2. Create an implementation called HandlingPricingEngineImpl that extends
PricingEngineService.

3. Create a HandlingPricingInfo that extends the AmountInfo price holding class.
(For more information, see AmountInfo.)

4. Create a calculator called HandlingPricingCalculator and implementations of it
that calculate and discount handling as your business requires
.
5. Modify the Promotions repository definition file (by default, pricingModels.xml).
Add an item-descriptor for the Handling discount type and sub-descriptors for the
various implementations of the HandlingPricingCalculator that you created.

6. Create properties files for the HandlingPricingEngine and each of the calculators.
Your engine is ready for use. You may also want to add preCalculators that calculate the base cost of
handling.

No comments:

Popular Posts