Echomeme Posted August 24, 2018 Share Posted August 24, 2018 Hi, I try to update a product with the webservice but no way, always got : 400 Bad request. On customer i have no problem, it's only on products. My Prestashop is a new install, version 1.7. I use https://github.com/PrestaShop/PrestaShop-webservice-lib for an easy way. There is my code : define('DEBUG', true); define('PS_SHOP_PATH', 'http://prestashopdomain.com'); define('PS_WS_AUTH_KEY', '8XKBE7ZK3ZSRExxxxxxxxxQLR2MXF'); require_once('./PSWebServiceLibrary.php'); $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'products'); $opt['id'] = '1'; $xml = $webService->get($opt); $resources = $xml->children()->children(); $resources->reference = 'demo_3b'; $opt = array('resource' => 'products'); $opt['putXml'] = $xml->asXML(); $opt['id'] = '1'; try { $webService->edit($opt); } catch (PrestaShopWebserviceException $ex) { echo $ex->getMessage(); } As you see, nothing particular... Can somebody help me ? Thanks :-) Link to comment Share on other sites More sharing options...
Echomeme Posted August 27, 2018 Author Share Posted August 27, 2018 Quote Can somebody save me Let your warm hands break right through and Save me I don't care how you do it Just stay, stay Oh come on I've been waiting for you A little humor in my despair... Link to comment Share on other sites More sharing options...
Echomeme Posted September 5, 2018 Author Share Posted September 5, 2018 I'm maybe the only one here who use the API... Link to comment Share on other sites More sharing options...
Sterk Posted November 6, 2019 Share Posted November 6, 2019 Hi Echomeme, you need to remove some data from your schema before update request : unset($xml->children()->children()->manufacturer_name); //mandatory unset($xml->children()->children()->quantity); //mandatory because this values are read only. PS: better to write one function to get product xml and another to update product 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now