Event hooks
The extension’s Javascript library provides a hooking system that allows developers to extend the HawkSearch functionality. At the moment the extensions provides the following hook names for triggering events throughout the front-end implementation:
processFacetsAfter
To add your hook, use the HawkSearchHooks.register
 method. This method accepts two parameters: name
- a hook name and callback
function.
Â
HawkSearchHooks.register('processFacetsAfter', function(json){
//Add your custom logic here
return json;
})
The event processFacetsAfter
fires as the following:
HawkSearch.triggerHook('processFacetsAfter', json);
The hook transfers the json
variable to the callback
function where it can be modified and returned back to the calling function.
Add hooks
We strongly recommend that you do not change the source code of default Hawksearch and Magento components. All customisations must be implemented in custom modules or themes.
When you are adding your hooks make sure that it is added before the event is triggered. You should follow the Magento custom JavaScript practices to specify the better approach for customising your store. One of the techniques is to deliver your custom JS file through the head section of theme layout:
<head>
<script src="Vendor_Module::custom_hooks.js"/>
</head>
The other approach is to add your file with the help of RequireJs.