Jump to content

Using API to get product description


Andre1972nrw

Recommended Posts

Hi,

 

to get a list of the products or - if id is set - the details works fine for me.

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
// Here we set the option array for the Webservice : we want customers resources
$opt['resource'] = 'products';
// We set an id if we want to retrieve infos from a customer
if (isset($_GET['id']))
 $opt['id'] = (int)$_GET['id']; // cast string => int for security measures
// Call
$xml = $webService->get($opt);
// Here we get the elements from children of customer markup which is children of prestashop root markup
$resources = $xml->children()->children();

 

But what I need are also the discription in the different languages.

In SQL is not very difficult but for the service I can't find the function for ...

SELECT ps_lang.language_code, ps_product.id_product, ps_product.date_upd, ps_product.id_category_default, ps_category_lang.name,
ps_product_lang.description, ps_product_lang.description_short
FROM ps_product, ps_product_lang, ps_lang, ps_category_lang
WHERE ps_product.id_product = ps_product_lang.id_product
AND ps_product_lang.id_lang = ps_lang.id_lang AND ps_lang.language_code =  'de'
AND ps_product.id_category_default = ps_category_lang.id_category
AND ps_product_lang.id_lang = ps_category_lang.id_lang

 

Can you help please?

 

Thanks

 

Andre

Link to comment
Share on other sites

Is display->'full' the right way for?

 

I tried out this

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
// Here we set the option array for the Webservice : we want customers resources
$opt['resource'] = 'products';
// We set an id if we want to retrieve infos from a customer
if (isset($_GET['id']))
{
 $opt['id'] = (int)$_GET['id']; // cast string => int for security measures
 $opt['display'] = 'full';
}
// Call
$xml = $webService->get($opt);
// Here we get the elements from children of customer markup which is children of prestashop root markup
$resources = $xml->children()->children();

 

But this seems to be the wrong way as (Store URL)/api/products/?display=full return the right result.

How to get the full detail for only one id?

 

Thanks

 

Andre

Link to comment
Share on other sites

  • 5 months later...

I have a problem related to a similar query like this. Can you help me?

 

When I try to get the list of all products, I get an empty response, the Content-Length is set to 0 in the response. However, if I specify the $opt['id']= 954; I was able to get a xml with the product details in the response.

 

I am not sure why the API is not working for me to get a list of all products, that in fact I need it to then iterate over the existing products.

 

I am using PS 1.5.2.0.

 

Did you have this same issue? Or can you help me to find a way to troubleshoot it?

 

Thanks.

 

 

 

It was my mistake as I tested with the wrong ID ...

ID 6 has just a "Lorem ipsum" as description and I did changes for an other ID :)

Link to comment
Share on other sites

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...