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
- Find the price rule element to override:
- 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
- Override the classes:
- ComparisonConditionElementCmdImpl
- PriceEquationCalculationCmdImpl
- PriceListElementCmdImpl
Replace the class names:
- MyComparisonConditionElementCmdImpl
- MyPriceEquationCalculationCmdImpl
- MyPriceListElementCmdImpl
- Open the HCL Commerce Developer.
- Open the Java™ EE
perspective.
- Expand the project WebSphereCommerceServerExtensionsLogic located
under src. Create a package named com.mycompany.commerce.price.rule.commands.element.
- Import the source code.
- Using the right mouse button, click the com.mycompany.commerce.price.rule.commands.element package.
- Click Import>GeneralFile
System. Click Next.
- Go to the temporary location where CustomizeGetEntitledPrice.zip
is and go to WebSphereCommerceServerExtensionsLogic\src\com\mycompany\commerce\price\rule\commands\element.
- Click all files and click Finish.
Click Yes to All to overwrite any existing
files.
- Organize the imports for the WebSphereCommerceServerExtensionsLogic
project.
- Open the Java™ perspective
in HCL Commerce Developer.
- Expand the WebSphereCommerceServerExtensionsLogc project,
right click src.
- Click Source>Organize
Imports.
- Insert the new CMDREG records to override the supplied implementations. Use the Data Load
utility; see Overview of the Data Load utility.
- Validate the customization by JUnit.
- Click File>Import.
- Click General>Existing
Projects into Workspace. Click Next.
- Browse to the temporary location where CustomizeGetEntitledPrice.zip
is, and click GetEntitledPriceExtension-UnitTests.
Check
Copy project into workspace
, and click Finish.
- 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.
- Click Window>Preferences.
- From Preferences, click Run/Debug>TCP/IP
Monitor.
- Click Add.
- Type the following information:
- Local monitoring port: 81.
- Host name: localhost
- Port: 80
- Type: TCP/IP
- Click OK.
- Click the created TCP/IP Monitor.
- Click Start.
- Click OK.
- Start the HCL Commerce test
server.
- Make sure the HCL Commerce is already published
to the HCL Commerce Test
Server. If it is not:
- In the Server pane, click the right mouse
button, and click the HCL Commerce Test
Server. Click Add and Remove Projects.
- Click the HCL Commerce Project.
- Click Add.
- 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.
- Modify GetEntitledPriceExtension-UnitTests/src/com/mycompany/commerce/price/facade/client/GetEntitledPriceTest.java,
to ensure that the values of the parameters are correct.
- Using the right mouse button, click GetEntitledPriceTest.java.
Click Run As>JUnit Test.
- Check the request and response messages in the TCP/IP
Monitor. Ensure that the results are correct.