Customizing the HCL Commerce pricing engine

You can create a price rule element to override the supplied price rule elements.

About this task

Price rules each have their own conditions. There are multiple price rule elements that are used to compose a price rule. The multiplying calculations are not done in the price rule element commands, otherwise the same value points can be multiplied more than one time. To avoid value points multiplied more than one time, the commands that output the offer price must be overridden, or used as a parameter. This tutorial teaches you how to customize the HCL Commerce pricing engine and create a price rule element class to use for your own business purposes.

To customize the HCL Commerce price engine:

Procedure

  1. Find the price rule element to override:
    1. Open HCL Commerce API, and go to the package com.ibm.commerce.price.rule.commands.element. In this package, these classes are listed:
      • CalculatePriceElementCmdImpl
      • CatalogConditionElementCmdImpl
      • ComparisonConditionElementCmdImpl
      • CoordinatorElementCmdImpl
      • CustomerConditionElementCmdImpl
      • NestedPriceRuleElementCmdImpl
      • PriceEquationCalculationCmdImpl
      • PriceListConditionElementCmdImpl
      • PriceListElementCmdImpl
      • PriceRuleElementCmdImpl
      • RoundingElementCmdImpl
      • DateConditionElementCmdImpl
    2. Override the classes:
      • ComparisonConditionElementCmdImpl
      • PriceEquationCalculationCmdImpl
      • PriceListElementCmdImpl
      Replace the class names:
      • MyComparisonConditionElementCmdImpl
      • MyPriceEquationCalculationCmdImpl
      • MyPriceListElementCmdImpl
  2. Open the HCL Commerce Developer.
  3. Open the Java EE perspective.
  4. Expand the project WebSphereCommerceServerExtensionsLogic located under src. Create a package named com.mycompany.commerce.price.rule.commands.element.
  5. Import the source code.
    1. Using the right mouse button, click the com.mycompany.commerce.price.rule.commands.element package.
    2. Click Import>GeneralFile System. Click Next.
    3. Go to the temporary location where CustomizeGetEntitledPrice.zip is and go to WebSphereCommerceServerExtensionsLogic\src\com\mycompany\commerce\price\rule\commands\element.
    4. Click all files and click Finish. Click Yes to All to overwrite any existing files.
  6. Organize the imports for the WebSphereCommerceServerExtensionsLogic project.
    1. Open the Java perspective in HCL Commerce Developer.
    2. Expand the WebSphereCommerceServerExtensionsLogc project, right click src.
    3. Click Source>Organize Imports.
  7. Insert the new CMDREG records to override the supplied implementations. Use the Data Load utility; see Overview of the Data Load utility.
  8. Validate the customization by JUnit.
    1. Click File>Import.
    2. Click General>Existing Projects into Workspace. Click Next.
    3. Browse to the temporary location where CustomizeGetEntitledPrice.zip is, and click GetEntitledPriceExtension-UnitTests. Check Copy project into workspace, and click Finish.
    4. Set up a TCP/IP Monitor in the HCL Commerce Developer. This TCP/IP Monitor is used to see the request and response messages travel between HCL Commerce and the external member management system.
      1. Click Window>Preferences.
      2. From Preferences, click Run/Debug>TCP/IP Monitor.
      3. Click Add.
      4. Type the following information:
        • Local monitoring port: 81.
        • Host name: localhost
        • Port: 80
        • Type: TCP/IP
      5. Click OK.
      6. Click the created TCP/IP Monitor.
      7. Click Start.
      8. Click OK.
    5. Start the HCL Commerce test server.
    6. Make sure the HCL Commerce is already published to the HCL Commerce Test Server. If it is not:
      1. In the Server pane, click the right mouse button, and click the HCL Commerce Test Server. Click Add and Remove Projects.
      2. Click the HCL Commerce Project.
      3. Click Add.
      4. Click Finish.

      If the HCL Commerce project is already added, click the right mouse button, and click the HCL Commerce Test Server and click Publish.

    7. Modify GetEntitledPriceExtension-UnitTests/src/com/mycompany/commerce/price/facade/client/GetEntitledPriceTest.java, to ensure that the values of the parameters are correct.
    8. Using the right mouse button, click GetEntitledPriceTest.java. Click Run As>JUnit Test.
    9. Check the request and response messages in the TCP/IP Monitor. Ensure that the results are correct.