Alex Sanchez Posted December 19, 2017 Share Posted December 19, 2017 Tengo este script para actualizar el precio de un producto en PrestaShop con WebServices. <html><head><title>CRUD Data Transfer - Update example</title></head><body> <?php // Here we define constants /!\ You need to replace this parameters define('DEBUG', true); define('PS_SHOP_PATH', 'https://my.domain.com'); define('ID_PRODUCT', 1); define('PS_WS_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'); require_once('./PSWebServiceLibrary.php'); @ini_set('display_errors', 'on'); try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $opt['id']=ID_PRODUCT; $xml = $webService->get($opt); echo "Successfully recived data."; /* List of nodes that can't modify * * - "manufacturer_name" * - "position_in_category" * - "quantity" * - "type" */ unset($xml->children()->children()->manufacturer_name); unset($xml->children()->children()->position_in_category); unset($xml->children()->children()->quantity); unset($xml->children()->children()->type); $xml->children()->children()->price = 111.0; // <-- new price! //Load new data to query generator $opt['putXml']=$xml->asXML(); $xml = $webService->edit($opt); // if WebService don't throw an exception the action worked well and we don't show the following message echo "Successfully updated."; } catch (PrestaShopWebserviceException $ex) { // Here we are dealing with errors $trace = $ex->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error<br />'.$ex->getMessage(); } ?> </body></html> ¿Cómo puedo hacer lo mismo, pero para todos los productos de una tabla MySQL? Tengo todos los productos en una tabla MySQL con la clave ID como Source_ID. Agradezco cualquier ayuda! Saludos Link to comment Share on other sites More sharing options...
Alex Sanchez Posted December 20, 2017 Author Share Posted December 20, 2017 Ni una sola respuesta?? Link to comment Share on other sites More sharing options...
scorsese Posted December 27, 2017 Share Posted December 27, 2017 Buenas tardes. ¿Lo quieres hacer con un Webservice o te serviría un fichero php ? Un saludo Link to comment Share on other sites More sharing options...
Alex Sanchez Posted January 3, 2018 Author Share Posted January 3, 2018 On 27/12/2017 at 6:10 PM, scorsese said: Buenas tardes. ¿Lo quieres hacer con un Webservice o te serviría un fichero php ? Un saludo Hola @scorsese, gracias por contestar!! Pues me es igual la verdad, me vale de cualquiera de las dos maneras. Agradezco tu ayuda!! Un saludo Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now