Jump to content

Update Product Attributes


alan.rodrigues

Recommended Posts

Hello, I'm trying to update the price of my products. The new price will be sent from our ERP. So I'will get it from SQL. Prestashop's returning the follow error:

 

Fatal error: Uncaught PrestaShopWebserviceException: This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request. in /var/inc/bibliotecas/PSWebServiceLibrary.php:91 Stack trace: #0 /var/inc/bibliotecas/PSWebServiceLibrary.php(359): PrestaShopWebservice->checkStatusCode(400) #1 /var/inc/atualizaPrestashop.inc(76): PrestaShopWebservice->edit(Array) #2 /var/www/diprotec/comando.php(11): Prestashop->NovoProduto() #3 {main} thrown in /var/inc/bibliotecas/PSWebServiceLibrary.php on line 91

 

 

Here my code:

 

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
         

          $id_product = '1335';
          $precoNovo = "6969";

          $xml_product = $webService->get(array('resource' => 'products', 'id' => $id_product));
          $resources_product = $xml_product->children()->children();

          unset($resources_product->price);

          $resources_product->price=$precoNovo;

          $opt = array('resource' => 'products');
          $opt['putXml'] = $xml_product->asXML();
          $opt['id'] = $id_product;
          $xml=$webService->edit($opt);
            }

Edited by alan.rodrigues (see edit history)
Link to comment
Share on other sites

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...