peorthyr Posted February 20, 2013 Share Posted February 20, 2013 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 Link to comment Share on other sites More sharing options...
peorthyr Posted February 20, 2013 Author Share Posted February 20, 2013 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 More sharing options...
Laeti-laeti Posted April 4, 2014 Share Posted April 4, 2014 (edited) If still useful to anyone... $webService->get(array('resource' => 'products', 'limit' => '1', 'sort' => '[id_DESC]', 'display' => '[id]')) ... just after the add call. Not great for performance but works! Edited April 4, 2014 by Laeti-laeti (see edit history) Link to comment Share on other sites More sharing options...
Eli Ivanova Posted June 13, 2014 Share Posted June 13, 2014 a better solution to retrieve the last created id after add call would be the following $xml = $webService -> add($opt); $result = $xml->children()->children(); $id_product = $result->{'id'}; 3 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