Overriding or Extending Functionalities
Last updated
Last updated
You can extend the functionality of Nosto module and modify what data is sent to Nosto.
In order to extend Nosto module, you must create a small Prestashop module. This way, you can override the data in product model, order model or any other functionality provided by Nosto module.
You need two configuration files for your custom module - the main module file and the actual module configuration that defines the overrides.
Below you can find an example module which you can simply copy&paste into your PrestaShop modules
folder inside your installation. Let's call the module My Nosto
. First create a folder, mynosto
, inside your PrestaShop modules
folder. Then copy paste these 2 files below into that new folder.
Note: if you cannot make changes directly inside your PrestaShop installation, you can create the mynosto
folder locally on your own computer and put the files inside it, after which you create a zip archive of the whole folder that you can then upload in your PrestaShop backend like any other module.
Creating an override requires a few files to be created. Follow the guide below and simply copy-paste the content into the specified locations. This will form the scaffold of your new override.
modules/mynosto/config.xml
modules/mynosto/mynosto.php
This file contains the actual override and follows the conventions of creating a standard Prestashop module. It is in this class that you will need to register the subscribers or hooks for whatever event you will be listening for.
Once you've got the module into your PrestaShop installation, you should see it inside your PrestaShop backend module listing. Click the Install
button next to the module to install it. Now you can start modifying the product information. The changes you make will be taken into use instantly both in the shop frontend (you can view the changes in the handy Nosto debug toolbar when navigating the product pages) and in the backend API requests.
If you are using PrestaShop 1.7 you should install the plugin through the command line using the command bin/console prestashop:module install mynosto
.
Please note that if you add or remove registered hooks you need to Reset the custom module in PrestaShop backend module listing.
Once you have overridden the associated model and customised whatever fields you may need, you should verify that it, in fact, working as expected.
A simple way to verify that the changes are working would be to log in as a customer and view any page with the Nosto debug-mode enabled. The debug mode can be enabled by adding the query parameter nostodebug=true
to the end of any URL. This will cause a helpful debug toolbar to appear where you can view the tagged data on the page. For more information on the debug-toolbar, please refer to this guide titled Nosto Debug Toolbar in our Support Center.
NOTE: Please note that in order to verify the changes using the debug-toolbar, you must have a Nosto account for the given store.
Nosto module dispatches following hooks.
NostoBrand
actionNostoBrandLoadAfter
NostoCart
actionNostoCartLoadAfter
NostoCategory
actionNostoCategoryLoadAfter
NostoCurrentUser
actionNostoCurrentUserLoadAfter
NostoCurrentVariation
actionNostoCurrentVariationLoadAfter
NostoCustomer
actionNostoCustomerLoadAfter
NostoExchangeRates
actionNostoExchangeRatesLoadAfter
NostoIframe
actionNostoIframeLoadAfter
NostoOauth
actionNostoOAuthLoadAfter
NostoOrder
actionNostoOrderLoadAfter
NostoProduct
actionNostoProductLoadAfter
NostoSearch
actionNostoBrandLoadAfter
NostoAccountBilling
actionNostoAccountBillingLoadAfter
NostoAccountOwner
actionNostoAccountOwnerLoadAfter
NostoAccountSignup
actionNostoAccountSignupLoadAfter
NostoOrderBuyer
actionNostoOrderBuyerLoadAfter
NostoOrderStatus
actionNostoOrderStatusLoadAfter
NostoVariationKeyCollection
actionVariationKeyCollectionLoadAfter