The following table describes the extension point details for the Promotions microservice.
EXTENSION POINT NAME | EXTENSION POINT DESCRIPTION/USAGE | EXTENSION INTERFACE METHOD SIGNATURE |
---|---|---|
Action | Indicates the class containing the custom code to process offers for the "fetch" and "apply" APIs based on the custom Action parameters. | boolean prepareApplyAction(PromotionOfferDO promotionOfferDO); void applyAction(PromotionOfferDO promotionOfferDO, PromotionDO promotion); void onFinish(PromotionOfferDO promotionOfferDO, PromotionDO promotion); |
ruleTypeProcessListener | Indicates the class name to implement the rule type processor listener. The promotion processor delegates the messages on every rule type executions to the rule type processor listener. This extension will be used as a reference implementation or a plug-in by the solutions team/System Integrator (SI) for processing the item level and cart level promotions in a single request when needed. | com.skava.promotion.rule.process.RuleTypeProcessListener |
Adding and Extending Promotion Data Models
There are two approaches to extend or create new data models, and make them available to business users to create a variety of offer permutations:
- Add a Temporary (For example, Seasonal) Custom Attribute to any data model (Business User task) To create a temporary custom field or attribute, select “property” in Query Builder for the desired data model. This will prompt to enter key:value data for the customer property in the model derived data maintained in an Infosys Equinox microservice such as Catalog. For example, Client B wants to add product attribute “IsHalloweenProduct” to a set of SKUs that are to be offered at a special price during a seasonal promotion. When creating promotions that target products with attribute
IsHalloweenProduct
the promotion author creates the Main condition rule using SKU model, selecting the property, and entering key:IsHalloweenProduct
, withvalue = true
. - Create a Permanent New Data Model with a New Set of Attributes (Developer task – SI Partner or Infosys Equinox Solutions) To create an entirely new model with custom fields, a custom JAR file is constructed to expose the new model and fields to the promotion engine. Note: Refer to the next section for more information.
Developing Custom Actions and Data Models
The Promotion microservice can accept any valid data model, allowing users to frame business rules (like Main conditions) based on the attributes in the model. When a condition rule is satisfied, actions defined in the promotion will evaluate. An action in an eCommerce context typically results in an update to a price attribute of a SKU when the condition rule is met, whereas a custom action is a user-defined action type that can operate against any data within a standard or extended model, thus supporting a much wider variety of use cases that are available out-of-the-box.
This section describes how models and actions can be customized, based on the needs of a hypothetical online book merchant.
The Online Book Store wants to create promotions that target offers based on genre, format, rating, and related attributes associated with their book catalog. However, this cannot be achieved with Infosys Equinox’s out-of-box SKU model, so the Store needs to write a custom “Book” model, containing attributes such as “id, title, genre, etc.”.
The first promotion that the Online Book Store marketing team wants to roll out is – “Get first 3 Months Free with an annual Subscription to any magazine by Hearst Publications”. To begin, the development team creates a new “Book” data model:
Book
id
title
genre - Fiction/Business/Biography/History/....
format - Electronic/Audio/Print/...
language
rating
yearlySubscriptionPrice
halfyearlySubscriptionPrice
quarterlySubscriptionPrice
publisher
publishedOn
isMagazine - True/False
isYearlySubscribed – True / False
isHalfyearlySubscribed – True / False
isQuarterlySubscribed – True / False
To author the promotion, the marketing team defines the following condition rule pattern:
Condition: ( Book.isMagazine == True AND Book. Publisher == “Hearst Publications” AND Book.isYearlySubscribed == True )
However, support for the promotion is not possible using standard Infosys Equinox actions, so the Online Book Store development team extends the service by writing a custom action “Product Subscription Offer” that gives the following response:
offers:
[
{
promotionId: ……...,
freeSubscriptions: 3,
}
]
Plugin Format: The custom model and action should be written as a plugin extension for the Promotion microservice. The extension will consist of a JAR file that contains a Maven project.
Setting up Dependency:
- Create an Eclipse Maven JAR project
- Add the following dependency definition in
pom.xml
to create an extension for the Promotion microservice.<dependency> <groupId>com.skava</groupId> <artifactId>promotion</artifactId> <version>8.0.0- RELEASE</version> </dependency>
-
Write a custom model in the following path:
\src\main\java\com\skava\promotion\<Group_Name>\model\
This contains the actual model and its attributes.For example,
\src\main\java\com\skava\promotion\book\model\Book.java
The following annotations can be used to define the attributes of the model:
Annotation Description RuleField.EXCLUDE_ALL
Signifies that the attribute will be excluded by Rule Engine while processing. RuleField.EXCLUDE_IN_ACTION_CONDITIONS
Signifies that the attribute will be excluded for the action condition by the Rule Engine while processing. RuleField.EXCLUDE_IN_CONDITIONS
Signifies that the attribute will be excluded for the condition by the Rule Engine while processing. RuleField.EXCLUDE_IN_STOP_CONDITIONS
Signifies that the attribute will be excluded for the stop condition by the Rule Engine while processing. Based on the above annotations, the attributes will not be served in their corresponding blocks (condition, stop condition, and action condition) in the GET “/rules/” API. So business rules cannot be framed by these attributes if this is excluded.
\src\main\java\com\skava\promotion\<Group_Name>\model\
contains the base class for the actual model and maps the response to the model.For example,
\src\main\java\com\skava\promotion\book\model\BookPromotion.java
-
The response of the custom model should be written in the following path:
\src\main\java\com\skava\promotion\<Group_Name>\model\
For example,
\src\main\java\com\skava\promotion\book\model\PromotionSubscriptionResponse.java
-
The Action of the custom model should be written in the following path:
\src\main\java\com\skava\promotion\<Group_Name>\action\
For example,
\src\main\java\com\skava\promotion\book\action\PromotionSubscriptionResponse.java
-
Compile as a JAR and add JAR reference into
{“loader.path”}
location which is configurable per application, typically/usr/local/skava/apps/promotions/plugins
which will be loaded as part of the Spring Boot application.
Additional References
See About Extending Infosys Equinox Commerce.
Revision History
2022-04-10 | JP – Fixed link and http issues.
2019-07-10 | AM – Updated extensions for July 2019 release.
2019-06-16 | PLK – Link added.
2019-05-17 | AM – Updated to a new table tool.
2019-01-23 | PLK – Page added and content uploaded.