• Home
  • Docs
    • User Manual
    • Magento 2 Manual
  • APIs
  • Back to Wizzy
  • Support
  • Home
  • Docs
    • User Manual
    • Magento 2 Manual
  • APIs
  • Back to Wizzy
  • Support
home/Knowledge Base/Magento 2 Manual/Advanced Setup

Frontend Events

110 views 0 July 9, 2021 alok

During the search/filtration process there are many event occurs where we might require to inject our frontend logic to change the default behaviour. Wizzy Magento 2 Extension provides frontend event hooks which can be implemented to modify the default behaviour or modify the parameters.

To see the supported event hooks, check the following file.

https://github.com/wizzy-ai/wizzy-search-magento-2/blob/dev/view/frontend/web/core/page.js

You can implement the event hooks in very simple steps,

  1. Inside Magento Admin Panel Go to Stores > Wizzy Search > Advanced Setup
  2. Select Yes in Overriding events.js (We’ve added this for developers to avoid creating new unnecessary layout files in their store theme core)
  3. Create new file module file under
    app/design/frontend/Theme/Namespace/Wizzy_Search/web/events/events.js

Register Hook

In this file you can register any required hooks from the list to modify the config or the store behaviour. To register a hook use global wizzy variable and it’s function registerEvent. If you would like to use jQuery or any other library as dependency in these hooks implementation make sure you add them in requirejs.

Something like this,

requirejs(['jquery'], function($) {
    wizzy.registerEvent(wizzy.allowedEvents.AFTER_PRODUCTS_TRANSFORMED, function(products) {

    });
});

Notes:

  1. Register event takes 2 parameters. One is the event type and second is callback function.
  2. After modifying the given parameters from callback function you must return the same.

Was this helpful?

Yes  No
Related Articles
  • Advanced Configuration
Leave A Comment Cancel reply

Advanced Setup
  • Frontend Events
  • Advanced Configuration
Categories
  • Magento 2 Manual
    • Advanced Setup
    • Autocomplete Menu
    • Catalog Index Configuration
    • Search UI Customisation
    • Setup
  • Shopify Manual
    • Setup
  • User Manual
    • Account
    • Analytics
    • Billing
    • Currencies
    • Developers
    • Stores
    • Synonyms
  • team@wizzy.ai
  • +91-9106141411
  • © 2021 Wizzy Softech Pvt. Ltd. All Rights Reserved