Good day, I have a problem
I use webservice to add products in prestashop, I have solved all the other issues by now, but this is getting me sick.
first of all, I use a cdata node for almost everything there, it goes good, but when it comes the description I have this code :
$xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/products?schema=blank'));
$resources = $xml -> children() -> children();$no = $node -> ownerDocument;
....
....
$node -> appendChild($no -> createCDATASection($n_desc));
$resources -> description -> language[0][0] = $n_desc;
$resources -> description -> language[0][0]['id'] = $n_l_id;
$resources -> description -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id;
....
....
try {
//print_r($xml);
$opt = array('resource' => 'products');
$opt['postXml'] = $xml -> asXML();
$xml = $webService -> add($opt);
return true;
} catch (PrestaShopWebserviceException $ex) {
//echo '<b>Error : '.$ex->getMessage().'</b>';
//$trace = $ex->getTrace();
//print_r($trace);
return false;
}
the description comes from:
$n_desc = $row['descrizione'];
and this is the response:
HTTP/1.1 500 Internal Server Error
Date: Wed, 26 Feb 2014 15:37:59 GMT
Server: Apache/2.2.16 (Debian)
Vary: Host,Accept-Encoding
X-Powered-By: PrestaShop Webservice
Access-Time: 1393429079
PSWS-Version: 1.5.6.1
Execution-Time: 0.026
then it comes all the xml sent, the description part is:
<description><language id="1" xlink:href="server.com/api/languages/1"><p><span style="font-size: 16px,">lorem ipsum dolor sit ...
I have try to encode it, real_escape, utf_encode, url encode... nothing.
edit of course if I send a description string like "description", all goes good.
does anyone has an idea? thanks in advance.