Jump to content

Add Combination via WEBSERVICE


Recommended Posts

Hello, hope you can guide me; 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;
    }*/
    //insert stock
    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>

Thanks!!

 

PD: Any guide to next step is grateful too! (add combination part)

Link to comment
Share on other sites

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