Jump to content

Can not get price [my_price] via API


easyjava

Recommended Posts

Hello,

I use the webservice to get some informations about a product. I need the final price so I use price[my_price][use_tax]=1 and it works very well with the url :

api/products/?filter[reference]=MY_PRODUCT_REF&display=full&price[my_price][use_reduction]=1

But when I try to do this via my php script, the my_price isn't returned.

<?php
$ref = "";
$url = "";
$key = "";
define('DEBUG', true);			// Debug mode
define('PS_SHOP_PATH', $url);	// Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', $key);	// Auth key (Get it in your Back Office)
require_once('PSWebServiceLibrary.php');
try{
	$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
	$opt = array(
    	'resource' => 'products',
		'display' => 'full',
		'filter[reference]' => $ref,
		'price[my_price][use_tax]' => '1'
	);
	$xml = $webService->get($opt);
	$resources = $xml->children()->children();
}
catch (PrestaShopWebserviceException $e){
	// Here we are dealing with errors
	$trace = $e->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 : '.$e->getMessage().'<br>'; 
}
echo 'id '.$resources->product->id.'<br>';
echo 'my price '.$resources->product->my_price.'<br>';
?>

Do you have an idea ?

I think I don't call my request properly but I do not find the mistake.

Thanks

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

  • 1 year 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...