Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ad-inserter domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cookie-law-info domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114
Abilitare CORS su PrestaShop 1.6 e 1.7 - Blog WebEats

Breve guida su come abilitare CORS su PrestaShop modificando il file dispatcher.php ed aggiungendo l’header Access-Control-Allow-Origin

Se state sviluppando un’app mobile per iOS e Android con Ionic o React, ed avete la necessità di accedere a dati dello store PrestaShop (clienti, prodotti, categorie e ordini), possiamo sfruttare tranquillamente le API integrate

Il problema però è che è necessario abilitare CORS affinchè le chiamate vengano gestite è necessario aggiungere 2 linee al file dispatcher.php locato nella cartella webservice

Colleghiamoci via FTP e scarichiamo il file

/webservice/dispatcher.php

editiamolo aggiungendo subito prima di ob_start();

header('Access-Control-Allow-Origin: *');

salviamo e ricarichiamo il file sull’FTP

Ora la nostra app con una chiamata async riceverà il feed dei prodotti senza problemi

Esempio link chiamata prodotti

https://www.site.com/api/products?ws_key=[PS_APIKEY]&display=[id,price,id_default_image,name,link_rewrite]&output_format=JSON