senecheikh Posted February 27, 2012 Share Posted February 27, 2012 Hi, i read the whole CRUD tutorial thing, fair to say it's incomplete ! the issue is that i can't add products using the webservice with POST, i get the error HTTP 400 bad request ... here is the code : require_once('PSWebserviceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml_product = $webService->get(array('resource' => 'products?schema=synopsis')); $resources_product = $xml_product->children()->children(); // champs requis $resources_product->quantity = 0; $resources_product->price = 1; $resources_product->out_of_stock = 2; $resources_product->name->language[0][0] = 'test'; $resources_product->link_rewrite->language[0][0] = 'test'; // par exemple pour vider les associations aux categories unset($resources_product->associations->categories->category); // associer a une categorie (id = 1) $resources_product->associations->categories->addChild('category')->addChild('id', 1); $xml_product = $webService->add(array('resource' => 'products', 'postXml' => $xml_product->asXML())); thanks Link to comment Share on other sites More sharing options...
Recommended Posts