For modifying Nosto's product data you must register hook actionNostoProductLoadAfter and implement corresponding action method. Below is an example of how your MyNosto class could look like.
File modules/mynosto/mynosto.php
<?phpif (!defined('_PS_VERSION_')) exit;/** * Module for overriding Nosto default behavior. * * Depends on the "Personalization for PrestaShop" module by Nosto. */classMyNostoextendsModule{/** * Constructor. * * Defines the module. */publicfunction__construct() {$this->name ='mynosto';$this->tab ='advertising_marketing';$this->version ='0.1.0';$this->author ='Nosto';$this->need_instance =1;$this->bootstrap =true;$this->ps_versions_compliancy =array('min'=>'1.4','max'=> _PS_VERSION_ );parent::__construct();$this->displayName =$this->l('My Nosto');$this->description =$this->l('Module for overriding Nosto default behavior'); }/** * Module installer. * * Registers the event listener for nosto events * * @returnbool */publicfunctioninstall() {return (parent::install()&&$this->registerHook('actionNostoProductLoadAfter') ); }/** * Action method for modifying the Nosto product information before it is used the shop frontend or the server-to-server API. * * The input params will always include: * * - "nosto_product" which is the NostoTaggingProduct instance that has just been loaded with data * - "product" which is the Prestashop Product model instance used as source for the data * - "context" which is the Prestashop Context model instance used when loading the data * * Modifying the instance in $params['nosto_product'] will directly reflect on the data that is sent to Nosto. The * NostoTaggingProduct class has a public API of setter methods to modify it's content. Some common use cases are * document in below method. * * You can find a full reference of the available product fields in the Nosto support center. * * @paramarray $params * * @see https://support.nosto.com/get-started/tagging-product-pages/ */publicfunctionhookActionNostoProductLoadAfter(array $params) {/** @varNostoProduct $nosto_product */ $nosto_product = $params['nosto_product'];/** @varNostoTaggingProduct $prestashop_product_product */ $prestashop_product = $params['product'];if ($nosto_product instanceofNostoProduct) {// Implement your customizations here $nosto_product->addTag3('nosto test'); $nosto_product->setPrice($nosto_product->getPrice()*1.2); $nosto_product->setName($nosto_product->getName().' - TEST OVERRIDE'); } }}
Verifying
Once you have overridden the product 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 view any product 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.
If you were to extend the product model using the example given above, you would see that the "Tags" field in the debug-toolbar will read "nosto".
NOTE: Please note that in order to verify the changes using the debug-toolbar, you must have a Nosto account for the given store.