Reputation: 118
hope you can guide me(because I dont find any real answer in other existing questions); my code is:
<?php
function make_product_options($data){
global $webService, $config;
/*try{*/
$xml = $webService->get(array('url' =>$config["ps_shop"].'api/product_option_values?schema=blank'));
$product_option_value = $xml->children()->children();
$product_option_value->id = 1;
$product_option_value->id_attribute_group = $data["id_attribute_group"];
$product_option_value->name->language[0][0] = $data["name"];
$product_option_value->name->language[0][0]['id'] = 1;
$opt = array('resource' => 'product_option_values');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
var_dump($xml);
die();
$product_option_value = $xml->product_option_values;
/*} catch (PrestaShopWebserviceException $e){
return;
}*/
return $product->id;
}
but i am getting "400 bad request" the xml sended is:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<product_option_value>
<id>1</id>
<id_attribute_group>4</id_attribute_group>
<color/>
<position/>
<name><language id="1">Logo Grande</language></name>
</product_option_value>
</prestashop>
Upvotes: 1
Views: 900
Reputation: 118
i solve it with the help of PixelWeb, here is the code i use:
https://gist.github.com/is-just-me/4dadabf7e5514dcc25cf7de51eac9d21
hope help somebody ;)
Upvotes: 0
Reputation: 568
name
value for every language in your shop.id
value must be empty. If not, could be interpreted as an update.Good luck.
Upvotes: 1