Poncy Posted April 6, 2022 Share Posted April 6, 2022 (edited) Hi, i'm trying to add a specific price with webservice, but return me an erorr: "ERROR: This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error." Why? This is my code: try{ $webService = $this->connPS(); $opt = array('resource' => 'specific_prices'); $xml = $webService->get(array('url' => PS_SHOP_PATH . '/api/specific_prices?schema=blank')); $product = $xml->children()->children(); unset($product->id); //unset($product->id_shop_group); $product->id_shop = 1; $product->id_cart = 0; $product->id_product = 553; $product->id_currency = 0; $product->id_country = 0; $product->id_group = 0; $product->id_customer = 0; $product->id_shop_group = 0; $product->id_product_attribute = 0; $product->id_specific_price_rule = 0; $product->reduction = 1; $product->reduction_tax = 1; $product->reduction_type = 'amount'; $product->price = -1; $product->from_quantity = 1; $product->from = "0000-00-00 00:00:00"; $product->to = "0000-00-00 00:00:00"; $opt = array('resource' => 'specific_prices'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); $product_price = $xml->specific_prices; } catch (PrestaShopWebserviceException $e){ // Here we are dealing with errors $trace = $e->getTrace(); if ($trace[0]['args'][0] == 404) return 'Bad ID'; else if ($trace[0]['args'][0] == 401) return 'Bad auth key'; else return '<b>ERROR:</b> ' . $e->getMessage(); } Edited May 14, 2022 by Poncy (see edit history) Link to comment Share on other sites More sharing options...
Poncy Posted April 13, 2022 Author Share Posted April 13, 2022 no one can help me Link to comment Share on other sites More sharing options...
Poncy Posted April 20, 2022 Author Share Posted April 20, 2022 UP Link to comment Share on other sites More sharing options...
Poncy Posted April 27, 2022 Author Share Posted April 27, 2022 (edited) This is the array before add() Array ( [resource] => specific_prices [postXml] => <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <specific_price> <id_shop_group>0</id_shop_group> <id_shop>1</id_shop> <id_cart>0</id_cart> <id_product>594</id_product> <id_product_attribute>0</id_product_attribute> <id_currency>0</id_currency> <id_country>0</id_country> <id_group>0</id_group> <id_customer>0</id_customer> <id_specific_price_rule>0</id_specific_price_rule> <price>-1</price> <from_quantity>1</from_quantity> <reduction>0.2</reduction> <reduction_tax>1</reduction_tax> <reduction_type>percentage</reduction_type> <from>0000-00-00</from> <to>0000-00-00</to> </specific_price> </prestashop> ) Edited April 27, 2022 by Poncy (see edit history) Link to comment Share on other sites More sharing options...
Sevarf2 Posted May 6, 2022 Share Posted May 6, 2022 (edited) Try to remove the empty line after the <specific_price> Edited May 6, 2022 by Sevarf2 (see edit history) Link to comment Share on other sites More sharing options...
Poncy Posted May 13, 2022 Author Share Posted May 13, 2022 Hi, the result is the same Link to comment Share on other sites More sharing options...
Poncy Posted May 13, 2022 Author Share Posted May 13, 2022 (edited) Hi, SOLVED!! the my problem is a test in a disabled product, if you try with an active product all work fine. Thanks to all Edited May 13, 2022 by Poncy (see edit history) 1 Link to comment Share on other sites More sharing options...
Nickz Posted May 13, 2022 Share Posted May 13, 2022 13 minutes ago, Poncy said: Hi, SOLVED!! the my problem is a test in a disabled product, if you try with an active product all work fine. Congrats, add solves in the title, that helps all. 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