Rule-based sales category overview

You can enable and administer rule-based sales categories to add support for applying a business user-defined and search-based rule to find and automatically assign catalog entries to the categories.

Rule-based sales categories are a type of sales categories that use a search-based, business user-defined rule with HCL Commerce search to find, and automatically assign catalog entries to the category. By enabling support for applying the rule, you can reduce the time that is needed for business users to assign or update the catalog entries for a category. Business users can create and use rule-based sales categories for almost the same purposes that they use regular sales categories. For instance, in addition to displaying the categories in your storefront, business users can use the categories in promotions, marketing activities, and Commerce Composer widgets. Business users can also view, approve, work on, and undo changes for the categories in workspaces. Users cannot use rule-based sales categories as parent categories or create versions of the categories.

For more information about how business users can create and use rule-based sales categories, see Rule-based sales categories.

Applying or reapplying the rule to a rule-based sales category involves the following process:

Architectural overview of rule-bases sales categories

1 When an event triggers the process to evaluate and potentially apply the rule, a call is made to the RuleBasedCategoryHelper utility class to begin the process. This class provides helpers to call the commands for evaluating which rules need to be applied or reapplied, for retrieving the catalog entries to assign to each category, and for assigning the catalog entries to the categories.

The following events can trigger the call to the RuleBasedCategoryHelper class to begin the process:
  • A business user saves a rule-based sales category in the Catalogs tool after they define or update the rule. The call to RuleBasedCategoryHelper class is for evaluating the rule for only the specific category.
  • A business user selects to reapply the rule in the Catalogs tool. The call for evaluating the rule is for only the specific category.
  • The time interval to run the EvaluateRuleBasedCategories job for a category is reached. The call for evaluating the rule occurs when the configured time interval for the evaluation job is reached for a category. This process runs separately for each category.
  • HCL Commerce EnterpriseA business user approves a task group in the Workspace Management tool that includes changes for one or more rule-based sales categories. Workspaces must be enabled. The call for evaluating the rule is for all categories that are flagged in the database as needing the rule evaluated.
  • an HCL Commerce search indexing operation completes. When the UpdateSearchIndex scheduled job that updates the search index completes, a call is made to the RuleBasedCategoryHelper to evaluate all of the rule-based sales categories. If an administrator calls the buildindex REST API, a call is also made to the RuleBasedCategoryHelper to evaluate all rule-based categories when the utility completes rebuilding the index.

    To call the RuleBasedCategoryHelper after the search indexing or index building completes, an event listener is included for the search processes. When an indexing process completes, the listener is triggered and calls for the evaluation of the rule for all categories that are flagged in the database as needing the rule evaluated. The event listener is configured in the HCL Commerce configuration file.

When the call for evaluating the rule is for all categories that are flagged in the database as needing the rule evaluation, the process runs to evaluate rules that have one of the following values in the CATGRPRULE.EVALUATING database column:
"2"
Indicates that the rule needs to be reevaluated. The EvaluateRuleBasedCategories job ignores whether the interval since the last time that the rule was evaluated does not exceed the value of the evaluationTimeInterval configuration property.
"0"
Indicates that the rule is not currently being evaluated or in need of being evaluated. Categories with this value are evaluated when the value for the evaluationTimeInterval configuration property is not "-1" or when the interval since the last time that the rule was evaluated exceeds the value of the evaluationTimeInterval property
"-2"
Indicates that the previous attempt to evaluate the rule for the category failed. Categories with this value are evaluated when the value for the evaluationTimeInterval configuration property is not "-1" or when the interval since the last time that the rule was evaluated exceeds the value of the evaluationTimeInterval property
After the rule is evaluated, and if needed reapplied, the time interval resets and the column value is reset to "0".
2 Depending on how the rule evaluation and application process is triggered, the RuleBasedCategoryHelper class can call either of the following commands:
RuleBasedCategoryEvaluationCmdImpl
The RuleBasedCategoryHelper class calls this command to populate the CATGPENREL database table with the relationships between catalog entries and a single rule-based sales category. When a business user selects to apply or reapply the rule for a category in the Catalogs tool, the helpers call this command directly. If an event triggers the process to reapply rules for multiple categories, the RuleBasedCategoryHelper class calls EvaluateRuleBasedCategoriesScheduledCmdImpl command directly.
EvaluateRuleBasedCategoriesScheduledCmdImpl
The RuleBasedCategoryHelper class calls this command when multiple rule-based sales category rules need to be reapplied. For example, when the UpdateSearchIndex scheduled job completes, an event listener triggers a call to reapply the rule for any category that is affected by the index process. When this command is called, the command determines the rule-based sales categories that need the rule to be reapplied. The EvaluateRuleBasedCategoriesScheduledCmdImpl command then calls the RuleBasedCategoryEvaluationCmdImpl to apply the rule for each category individually.

The RuleBasedCategoryEvaluationCmdImpl command calls the following operations to evaluate whether a rule needs to be applied to a category, and if necessary to apply the rule.

3 The catalog services retrieve the rule for the category from the CATGRPRULE database table. Only the most current rule for a category is stored in this table.

4 The catalog services use the search filter conditions and specified catalog entries to include in the category to construct a search query for use with HCL Commerce search.

5 HCL Commerce search uses the query to retrieve the list catalog entries that match the rule from the search index. The retrieved catalog entries are sorted based on the defined sort criteria.

6 The catalog services compare the list of catalog entries that are retrieved by HCL Commerce search with the catalog entries that are currently assigned to the category. If there is a change, the catalog services remove the currently assigned catalog entries from the category and assigns the new list of catalog entries. If a business user changes the sort criteria for catalog entries, the list of catalog entries is considered changed and the assigned catalog entries are replaced. The relationships between the catalog entries and the category are stored in the CATGPENREL database table.

If there is not any change between the list of catalog entries that is retrieved from the search index and the catalog entries that are currently assigned, the assigned catalog entries are not replaced.
Note: If a catalog entry is specified by a business user and it matches the search filter conditions, the catalog entry is included only once in the category. The placement of the catalog entry in the category depends on the display option that is selected by the business user. If a business user selects to display the specific catalog entries before the catalog entries that match the search filter conditions, the catalog entry displays before the catalog entries that match the search filter conditions. The catalog entry displays according to the sequence that the business user sets for the catalog entries that display before the catalog entries that match the search filter conditions. If the business user selects to display specific catalog entries after the catalog entries that match the search filter conditions, the catalog entry displays within the list of catalog entries that match the search filter conditions according to the sort criteria for those catalog entries.

7 The catalog services update CATGRPRULE.EVALUATING column value for the category to be "0". If the EvaluateRuleBasedCategories job is configured to run, the time interval before the job next runs is reset for the category. The rule for the category is not evaluated again until this time interval is reached or another event triggers the rule evaluation process.

8 When the rule application process completes for all categories that were being evaluated, a call is made to HCL Commerce search to rebuild the index for the updated categories.

Enabling rule-based sales categories

By default, business users can create, change, and rule-based sales categories and define the rule for a category, but not apply the rule. To apply the rule to a rule-based sales category, you must enable the application of the rule. After you enable the application of rules, you can configure the rule evaluation process to automatically reapply the rule for each category after a specific amount of time elapses from the last time that the rule was reapplied. For more information, see Enabling rule-based sales categories.

Considerations and limitations

Before you enable support for applying rule-based sales category rules, ensure that you review and are aware of the following considerations and limitations:
  • By default, you cannot evaluate and apply a rule to a category in a production environment since this process can affect performance. If you want to update a category that is in the production environment to include catalog entries that are also in your production environment, copy the data into your authoring or staging environment. Then, reapply the rule in the authoring or staging environment and propagate the updated category back to the production environment.
  • You cannot create or place a rule-based sales category as a parent category. Rule-based sales categories can exist in a sales catalog hierarchy only as child categories.
  • You cannot use the Catalog Entries List for a rule-based sales category to manually assign catalog entries the category. You can manually assign catalog entries to a rules-based sales category within the Add specific catalog entries to this category section of the properties view Rule tab for the category.
  • You must use attribute dictionary attributes that are for use in merchandising when you select to use an attribute in a search filter condition.
  • You must index catalog entries with HCL Commerce search before the catalog entries can be found and assigned to any rule-based sales category.
  • You cannot create, update, or delete rule-based sales categories with any loading utilities, such as Catalog Upload.
  • You cannot use content versioning with rule-based sales categories.
  • You cannot link a rule-based sales category to another sales category.
  • HCL Commerce EnterpriseWhen workspaces are enabled, you cannot use quick publish to publish a rule-based sales category and the catalog entry assignments for the category to production. Request that an administrator use the stagingprop utility to publish your rule-bases sales category data to production and run the indexprop utility to update the search index.

    When a task group that includes a rule-based category is approved, the category properties and rule are merged into approved content, not the catalog entry assignments. The task group approval process sets the CATGRPRULE.EVALUATING column value for the new or changed rule-based sales categories to be "2". When the EvaluateRuleBasedCategories job next runs, the rules for these categories are evaluated and applied. Since the catalog entry assignments from within the workspace are not merged into approved content, the assignments are not available for quick publish.