Unique parameter must take :
'resource' => Resource name ,
'id' => ID of a resource you want to edit,
'putXml' => Modified XML string of a resource
Examples are given in the tutorial
public function edit($options)
{
$xml = '';
if (isset($options['url'])) {
$url = $options['url'];
} elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) {
$url = isset($options['url']) ? $options['url'] : $this->url . '/api/' . $options['resource'] . '/' . $options['id'];
$xml = $options['putXml'];
if (isset($options['id_shop'])) {
$url .= '&id_shop=' . $options['id_shop'];
}
if (isset($options['id_group_shop'])) {
$url .= '&id_group_shop=' . $options['id_group_shop'];
}
} else {
throw new PrestaShopWebserviceException('Bad parameters given');
}
$request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml));
self::checkStatusCode($request['status_code']);
// check the response validity
return self::parseXML($request['response']);
}
echo 'Other error'; } } } // Second : We update the data and send it to the web service if (isset($_GET['id']) && isset($_POST['id'])) { // Here we have XML before update, lets update XML with new values foreach ($resources as $nodeKey => $node) { $resources->{$nodeKey} = $_POST[$nodeKey]; } // And call the web service try { $opt = array('resource' => 'customers'); $opt['putXml'] = $xml->asXML(); $opt['id'] = $_GET['id']; $xml = $webService->edit($opt); // if WebService don't throw an exception the action worked well and we don't show the following message echo "Successfully updated."; } catch (PrestaShopWebserviceException $ex) { // Here we are dealing with errors $trace = $ex->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<br />' . $ex->getMessage(); } } }