Creating the rule-based sales category evaluation scheduled job

You can create the EvaluateRuleBasedCategories job command to reapply the rules for rule-based sales categories on a configured time interval. The evaluation time interval for each category begins from the last time that the rule was applied to that category. When the scheduled job runs, the existing catalog entry assignments for the category are replaced with the catalog entries that currently best match the rule.

Attention: You do not need to manually schedule this job. This job runs automatically after the UpdateSearchIndex scheduled job or buildindex REST call runs successfully.

After the UpdateSearchIndex job or buildindex REST call runs successfully, an event listener triggers a call to the EvaluateRuleBasedCategories job to evaluate all rule-based sales categories. This event listener call ensures that rule-based sales categories include the latest search index contents.

If you do want to create and run a scheduled job to call the EvaluateRuleBasedCategories job to evaluate the rule for all rule-based sales categories, do not configure the job to run on a scheduled interval. If you want to evaluate the rule for categories without waiting for the UpdateSearchIndex job to complete, run the job directly. If you want to run the job because the rules are not evaluated and applied often enough, consider decreasing the schedule interval of the UpdateSearchIndex job and configuring a shorter time interval to automatically evaluate the rules instead. For more information about configuring the evaluationTimeInterval property in the wc-admin-component.xml file, see Enabling rule-based sales categories.

Before you begin

Procedure

  1. Enable the configuration properties to add support for reapplying the rule for a rule-based sales category with a scheduled job.
    When you are working with the wc-admin-component.xml catalog component configuration file, ensure that you configure the following values for the appropriate configuration properties:
    • Set the value for the evaluationEnabled configuration property to "true" to enable the application of a rule to a rule-based sales category.
    • Set the value for the evaluationTimeInterval configuration property to a positive value. This value is the time interval in seconds that elapses before the scheduled job runs to apply the rule for a category.
    • Set the value for the evaluationHostname configuration property to ensure that the scheduled job runs on only a single node.
    Note: By default, you cannot configure the EvaluateRuleBasedCategories scheduled job to run in a production environment. When the EvaluateRuleBasedCategories job runs, a check is performed to determine whether the environment that the job is running in has workspaces or a staging environment configured. If neither configuration exists, the evaluationEnabled property for enabling the application of rules to rule-based sales categories is disabled.
  2. Open the Administration Console and select Site on the Administration Console Site/Store Selection page.
  3. Click Configuration > Scheduler. A list of jobs that are scheduled to run is displayed.
  4. Create the EvaluateRuleBasedCategories scheduled job:
    1. Click New.
    2. Create the EvaluateRuleBasedCategories job with the following values:
      New Scheduled Job: EvaluateRuleBasedCategories
      Parameter Value
      Job command EvaluateRuleBasedCategories
      Job parameters Enter the following parameter. You must pass in these parameters even when the values are empty strings.
      • catalogId
      • storeId
      • workspaceId
      • taskGroupId
      • taskId
      • syncType
      For example, catalogId=&storeId=&workspaceId=&taskGroupId=&taskId=&syncType=DELTA
      Note: The syncType parameter is used to trigger a comparison of the existing catalog entry assignments for a category and the current catalog entries that match the rule for the category. When the value for the parameter is DELTA, the rule is applied only when the current list of matching categories differs from the existing catalog entry assignments for the category. You can also set the value to be FULL to prevent the rule evaluation process from performing a comparison. Instead, the EvaluateRuleBasedCategories job always replaces the existing catalog entries assignments with the new list of catalog entries that match the rule.
      Start date Enter the current date.
      Start time Enter a time that you want to start the job for the first time.
      Associated user Enter your administrative user name.
      Allowed host Enter the hostname where you want to run the job. If a host is configured to be the dedicated host for running the job, use that host. An administrator can configure this host by setting the host name as the value for the evaluationHostname property in your custom wc-admin-component.xml file.
      Schedule interval Enter 0 as the value so that the job does not start running continuously.
      Note: You are recommended to not configure a time interval for the EvaluateRuleBasedCategories scheduled job to run by using this parameter. Since the UpdateSearchIndex scheduled job automatically triggers the EvaluateRuleBasedCategories job to run, edit the schedule interval value for that scheduled job to control when the EvaluateRuleBasedCategories runs.
      Job attempts Enter 0.
      Seconds to retry Enter 0.
      Scheduler policy Enter Run only once.
      Job priority Enter the priority for the job.
      Application type Enter Default as the type.

      For more information about the full set of parameters for scheduled jobs, see Scheduling a site-level job.

    3. Click OK.

Results

Your EvaluateRuleBasedCategories job is listed on the Scheduler Status Display page and runs at the specified start time. When the configured time interval elapses for a category, the scheduled job runs again to reapply the rule. This interval is the value that you set for the evaluationTimeInterval configuration property.