Jump to content

Webservice & Price managment


Recommended Posts

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt['price[prezzo][use_tax]']= '0';
$xmlProducts = $webService->get($opt);


I would use this feature on the webservice but the price I always returns 0, so the formula is right to create it ?



Link to comment
Share on other sites

you are looking for a product price so you have to query first the products webservice
//create new webservice
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);

//define resource access, returned fields and filters 			
$opt = array ( 
        'resource' => 'products' ,                        
	'display'  => '[id,name,price,id_tax_rules_group]       
//you can add a line filter above on product id (remember to add comma in the line before)
/*'filter[id]' => '[your product id]'*/

//call webservice					
$xml = $webService->get($opt);

//get the elements from children of products
$prods = $xml->products->children();

//get your output
foreach ( $prods as $item ){
    $prodName = $item->xpath('name/language[@id=1]') //if your language is 1
    echo (string)$item->id.' > '.$prodName.' > price is '.(string)$item->price; 

I suggest you to enable debug ( define(DEBUG,true) ) in order to check server response.

You can check all the fields of products with following command:

$xml = $webService->get(array('url' => 'your_prestashop_url/api/products?schema=synopsis'));


$xml = $webService->get(array('url' => 'your_prestashop_url/api/products?schema=blank'));

To get the field list of products:

//change your prestashop url in the following line
$xml = $webService->get(array('url' => 'your_presta_shop_url/api/products?schema=blank'));
$resources = $xml->children()->children();
echo '<table>';
   foreach ($resources as $key => $resource) {
        echo '<tr><td>' . $key . '</td></tr>';
echo '</table>';

I hope this will help you.

Have fun !

Edited by swina (see edit history)
Link to comment
Share on other sites


I don't understand what you need the webservices for. I mean if you explain me what are your needs I can try to help you better.

Using webservices you can get or even create/update/delete data in ps database outside from prestashop core.

I am using webservices for a web app in order to create orders out of webstore.


Have a good day

Link to comment
Share on other sites

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...