There may be a use-case or business requirement in which a modification to the Search query or display template is needed.
Once you have established the prerequisite code for overrides, you are free to focus on the custom action(s) necessary for your application within the Klevu scope, including and parameters.
This guide will familiarize with the actions involved in preparing for Template JS overrides
- Defer initialization (powerUp) of the Klevu component
- Define a new custom event
- Listen for the new custom event
- Fire the custom function, action, or override an API parameter
- Activate initialization (powerUp)
Note that each action requires definition within the corresponding scope of the override. We will note these where applicable below.
For Klevu Recommendations there are a series of convenient that can be utilized in place of these steps.
First we need to tell Klevu not to power up the appropriate module until we integrate the overrides. This flag will be updated at a later step.
You can place it as an additional options element.
Note the scope of the deferred powerUp in this example is set to landing.
Next we will create a new custom build event which will fire once Klevu has completed its initial setup.
Unique value used to attach it to the event lister
function and logic
Asynchronously retry X times
Wait X milliseconds between each retry
This event will loop using the maxCount and delay values.
When the Klevu internal flag setRemoteConfigLanding.build to be set as TRUE, any attached events will fire.
Note that this internal settings.flag being checked is in the landing scope. A separate build event check is required for each scope in each context of the override.
QuickSearch configuration is ready
Landing page configuration is ready
Category Page configuration is ready
The name we have chosen for this example is myLandingPageOverride but you can name this whatever you like. We will use this name to attach it to the event lister in the next step.
We will now establish an event listener that is attached to the build event defined as myLandingPageOverride in the previous step.
Please reference the applicable documentation sections for more detail on how to or parameters.
Finally, now that we have completed our overrides, we can tell Klevu that we are done and allow it to power up.
Landing page search query overrides the default limit for filter options in the result set