Jump to content

[SOLVED] Webservice specific_prices problem


Poncy

Recommended Posts

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 by Poncy (see edit history)
Link to comment
Share on other sites

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 by Poncy (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
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

  • Poncy changed the title to [SOLVED] Webservice specific_prices problem

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