HCL Commerce Enterprise

Price rule data storage and process flow

If you are customizing price rules, you should know which database tables store data about price rules. In addition, you should understand what is happening behind the scenes when your store displays a price generated by a price rule. This knowledge helps you understand what you need to create or change to support customized conditions and actions in price rules.

Tip: In the context of customization, conditions and actions are also called price rule elements.

Where data about price rules is stored

Business users create a price rule using the Price Rule Builder in the Catalog Filter and Pricing tool in Management Center. The following illustration shows which database tables are updated when a business user saves a price rule in the Price Rule Builder:
Price rule authoring tables

A behind-the-scenes look at a price rule in use on the storefront

When a customer views a store page that displays prices, HCL Commerce uses the price rule to set the price to which the customer is entitled. In a typical price rule, HCL Commerce evaluates conditions and performs actions in the price rule:
  • Condition elements are used in price rules to assign a condition to a path. For example, a Catalog Condition element might require that the catalog entry being priced must be in the Tires category. If the condition is met, then the path containing the condition element is used to set pricing. Other examples of conditions are the Customer Condition element and the Comparison Condition element. For detailed information about conditions, see Conditions in price rules.
  • Action elements are used in price rules to provide the instructions that WebSphere Commerce follows to set prices. Examples of actions are the Get Price from Price List action and the Calculate Price action. For detailed information about actions, see Actions in price rules.
Consider the following example price rule, which contains conditions and actions:
  • The top path sets prices for tires by getting a price from the Tire Prices price list and marking the price up by 10%.
  • The bottom path sets prices for all other catalog entries by getting a price from the Offer Price list.

A price rule example

If the customer opens a store page that displays a tire, the conditions and elements in the top path work like this:

  • 1 The Catalog Condition element checks whether the catalog entry is a tire. If so, the top path is used to set a price for the tire.
  • 2 The Get Price from Price List action retrieves the price of the tire from the Tire Prices price list, and passes the price to the next action in the flow.
  • 3 The next action is Calculate Price. This action marks the price up by 10%. Since this is the last action on the top path, the marked up price is displayed on the store page for the tire.

Note that if the customer opens a store page that displays a catalog entry that is not a tire, the bottom path is used for pricing.

The following illustration shows what happens behind the scenes when a price rule with conditions and actions like the previous example is in use on the storefront (only the top path is used in this explanation):


How a price rule is processed

For each step in the illustration, the following notes explain how the price rule engine processes the price rule to display a price for a catalog entry:

  • 1 When a customer shopping on the storefront views a store page that displays prices for a catalog entry:
    • To display the offer price (the price the customer is entitled to pay), WebSphere Commerce uses the com.ibm.commerce.catalog.beans.CatalogEntryDataBean. This data bean calls the implementation of the com.ibm.commerce.price.commands.GetContractUnitPriceCmd class, which invokes the price rule engine by:
      1. Passing in eligible contracts.
      2. Getting the price rule for the offer price that is assigned to each eligible contract.
      3. Determining the final price or prices to display after evaluating the applicable price rules.
    • To display the list price (the price that is for display purposes only), WebSphere Commerce calls the Get DisplayPrice service, which invokes the price rule engine by:
      1. Passing in the List price rule name directly.
      2. Determining the final price to display after evaluating the List price rule.
  • 2 If the price rule contains a condition element, the pricing services call the condition task command defined in the associated price rule element template definition. The pricing services pass the task command all the parameters specified in the associated price rule element template. Typically, business users define these parameters in the user interface, and the parameters are stored in the PRELEMENTATTR table as name-value pairs; however the parameters can also come from the specification in the price rule element template. These element parameters, plus any business context parameters such as the storeId and currency, are passed to the task command. The task command uses this information to determine if the condition is met. If not, then the task command returns false, and HCL Commerce ignores this path and moves to the next path in the price rule (next path not shown).
  • 3 To perform the first action in the price rule, the pricing services call the action task command defined in the associated price rule element template definition. The pricing services pass the task command all the parameters specified in the associated price rule element template definition. Typically, business users define these parameters in the user interface and the parameters are stored in the PRELEMENTATTR table as name-value pairs; however the parameters can also come from the specification in the price rule element template definition. These element parameters, plus any business context parameters such as the storeId and currency, are passed to the task command. The task command uses this information to perform the action in the price rule.
  • 4 To perform additional actions in the price rule, the pricing services follow the same process as described in 3. To pass the price output from the previous action to the next action in the flow, the price rule engine sets the output price as a variable called prOutputObject. This variable is one of the parameters in the processElement method.
  • 5
    • For the offer price, HCL Commerce returns the price that the price rule assigned to the contract generates to the Get EntitledPrice service. Since this service is invoked from the CatalogEntryDataBean, the data bean gets the returned price and passes the price to the JSP page for display.
    • For the list price, HCL Commerce returns the price generated by the List price rule to the Get DisplayPrice service. Since this service is invoked directly from the JSP page, the service parses the price from the returned logical data object and displays the price directly on the page.