Привет, ребята, я пытаюсь добавить новый продукт через веб-службы с помощью PSWebServiceLibrary, я пытался читать другие сообщения в этом форуме, но у меня проблемы.Prestashop WebService: Добавить продукт
Вот мой код:
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;
}
Когда я запускаю этот несильно он дает мне ошибку:
This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request.
Я думаю, что есть своего рода проблемы с «требуется = True» параметров, но я не знаю, что делать.
Спасибо.