The PricingEngineService
class is a GenericService
implementation of a PricingEngine
. PricingEngine
implementations can extend this class to leverage scheduling, global promotions, locale, and other configuration functionality.
The PricingEngineService
includes the getCalculatorForCalculatorType()
method, which determines the calculator component to use for promotions (note that it is not used for pre- or post-calculators). To make this determination, it consults a Map in which the key is a CalculatorType
. The calculator type specified in the PMDL is used to identify the correct calculator component. The calculator identified by getCalculatorForCalculatorType()
is then used by the pricing calculator (such as ItemPriceCalculator
). You can use the map to extend the pricing engine and add your own calculators to the pricing system.
Note: Only use the calculator type Map for promotions created in Commerce 10 or later. Earlier versions use a different mechanism for retrieving calculator details.
The QualifiedItems
and MatchingObjects
are passed to the calculator using the “extra parameters” Map. For the ItemPricingCalculator
, the List of QualifiedItem
objects is stored in Constants.QUALIFIED_ITEMS.
For Order
, Shipping
, and TaxPricingCalculators
, the MatchingObject
is stored in Constants.MATCHING_OBJECT
. For both, the DiscountStructure
is stored in Constants.DISCOUNT_STRUCTURE
.