Jump to content

Webservice : How To Retrieve The Last Inserted Id Of A Resource


peorthyr

Recommended Posts

well, as always i've got a problem that nobody here will solve, but i'll post here just to let you know that there is someone with the same problem with you, i'll obviusly post the solution as i will find it:

 

problem, during the insertion of a product via webservice, it is mandatory to update the stock_availables service, so i would like to know the last combination inserted via webservice... surely there is no way to do this, and i will have to search for that combinations starting from the name of the attributes... this webservice thinghy is quite hard to use, without any FUNCTIONAL documentation... and don't call those 3 pages on doc.prestashop "documentation"

 

thanks in advance, but i know that as always, this question will remain empty until i'll write again :D

Link to comment
Share on other sites

as always...

here how i find a sotk vavailability knowing the IDs of the product_option_values:

 

$webServiceCE = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, FALSE);
$opt = array('resource' => 'combinations');
$xml = $webServiceCE->get($opt);
$resources = $xml->children()->children();
foreach ($resources as $resource)
{
 $webService_int = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, FALSE);
 $opt_int = array('resource' => 'combinations');
 $opt_int['id'] = $resource->attributes();
 $xml_int = $webService_int->get($opt_int);
 $resources_int = $xml_int->children()->children()->associations->product_option_values->children();
 $trovata = 0;
 foreach ($resources_int as $resource_int){

  if ($resource_int->id == $id_colore || $resource_int->id == $id_taglia ){
   $trovata += 1;
  }

 }
 if ($trovata == 2){  
  return $resource->attributes();
 }
}

 

what a shame that you have such a nice program, like prestashop, but ANY KIND OF SUPPORT HERE!!!!!!!!!!!!!!!

by the way, this function i have posted unluckily doesnt' work, becouse if i called inside the loop if insertions of combinations, it returns always null (due to the recursion tail i guess... having some kind of search could be nice... but you know, these words will never be read.

Link to comment
Share on other sites

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