Joubinho Posted April 24, 2020 Share Posted April 24, 2020 (edited) Bonjour à tous, Auriez-vous un exemple de script utilisant "PSWebServiceLibrary" afin ajouter un groupe (déjà existant) à un client ? Par exemple, mon customer ayant l'id 2 appartient au groupe id3 et id4. Et j'aimerai qu'il soit en plus dans le groupe id7. Comment faire cela ? Cordialement. Edited April 24, 2020 by Joubinho Résolu (see edit history) Link to comment Share on other sites More sharing options...
Joubinho Posted April 24, 2020 Author Share Posted April 24, 2020 function add_to_group($customer_id, $group_id) { require __DIR__.'/PSWebServiceLibrary.php'; $url = 'xxxxxxxx'; $key = 'xxxxxxxxxx'; $debug = true; $webService = new PrestaShopWebservice($url, $key, $debug); $xml = $webService->get(['resource'=>'customers', 'id'=>$customer_id]); $new_group = $xml->customer->associations->groups->addchild('group', ''); $new_group->addchild('id', $group_id); $updatedXml = $webService->edit([ 'resource' => 'customers', 'id' => (int) $customer_id, 'putXml' => $xml->asXML(), ]); return; } Voici la réponse si vous aviez le même problème. 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