Jump to content

Recommended Posts


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');

$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 {
} catch (PrestaShopWebserviceException $ex)
	echo $ex->getMessage();

As you see, nothing particular...

Can somebody help me ? Thanks :-)

Share this post

Link to post
Share on other sites

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...

Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More