Это мой код:
Код: Выделить всё
function AddProduct($root_path, $authentication_key, $id, $name, $desc, $cat, $qta, $price){
try{
$webService = CreateWebServer($root_path,$authentication_key);
$xml = $webService->get(array('resource' => 'products?schema=synopsis'));
}catch(PrestashopWebserviceException $ex){
echo $ex->getMessage();
return -1;
}
$resources = $xml->children()->children();
unset($resources->position_in_category);
unset($resources->manufacturer_name);
$resources->price = floatval($price);
$resources->quantity = intval($qta);
$resources->link_rewrite->language[0][0] = str_replace(' ','-',$name);
$resources->name->language[0][0] = $name;
$resources->description->language[0][0] = $desc;
$node= dom_import_simplexml($resources->description->language[0][0]);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($desc));
$resources->associations = '';
//echo $xml->asXML();
try{
$opt = array('resource' => 'products');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
}
catch(PrestaShopWebserviceException $ex)
{
echo $ex->getMessage();
}
return 0;
}
Этот вызов Веб-службы PrestaShop завершились сбоем и вернули статус HTTP 400. Это означает: неверный запрос.
Я думаю, что возникла какая-то проблема с "required=true", но я не знаю, что делать.
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/270 ... -a-product
Мобильная версия