Jump to content

create product via webservice


ozgurkuru

Recommended Posts

Helle

 

I try to create products from web service but I have 400 error.

my code is:

 


    $opt = array('resource' => 'products');


    $xml = $ps->get(array('url' => 'http://sirtcantasi.org/api/products?schema=blank'));
  
  $psXML= <<<XML
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<product>
    <id></id>
    <id_manufacturer></id_manufacturer>
    <id_supplier></id_supplier>
    <id_category_default></id_category_default>
    <new></new>
    <cache_default_attribute></cache_default_attribute>
    <id_default_image></id_default_image>
    <id_default_combination></id_default_combination>
    <id_tax_rules_group></id_tax_rules_group>
    <position_in_category></position_in_category>
    <type></type>
    <id_shop_default></id_shop_default>
    <reference></reference>
    <supplier_reference></supplier_reference>
    <location></location>
    <width></width>
    <height></height>
    <depth></depth>
    <weight></weight>
    <quantity_discount></quantity_discount>
    <ean13></ean13>
    <upc></upc>
    <cache_is_pack></cache_is_pack>
    <cache_has_attachments></cache_has_attachments>
    <is_virtual></is_virtual>
    <on_sale></on_sale>
    <online_only></online_only>
    <ecotax></ecotax>
    <minimal_quantity></minimal_quantity>
    <price></price>
    <wholesale_price></wholesale_price>
    <unity></unity>
    <unit_price_ratio></unit_price_ratio>
    <additional_shipping_cost></additional_shipping_cost>
    <customizable></customizable>
    <text_fields></text_fields>
    <uploadable_files></uploadable_files>
    <active></active>
    <redirect_type></redirect_type>
    <id_product_redirected></id_product_redirected>
    <available_for_order></available_for_order>
    <available_date></available_date>
    <condition></condition>
    <show_price></show_price>
    <indexed></indexed>
    <visibility></visibility>
    <advanced_stock_management></advanced_stock_management>
    <meta_description><language id='1'></language></meta_description>
    <meta_keywords><language id='1'></language></meta_keywords>
    <meta_title><language id='1'></language></meta_title>
    <link_rewrite><language id='1'></language></link_rewrite>
    <name><language id='1'></language></name>
    <description><language id='1'></language></description>
    <description_short><language id='1'></language></description_short>
    <available_now><language id='1'></language></available_now>
    <available_later><language id='1'></language></available_later>
</product>
</prestashop>
XML;


$xml = new SimpleXMLElement($psXML);


$xml->product->id_category_default=$cat;
    foreach($val->STOK_ADI as $d){
      $isim = $d;
      break;
    }
$xml->product->name->language[0]=$isim;
$xml->product->link_rewrite->language[0]=replaceTr($isim);
$xml->product->price=$fiyat;


   // var_dump($xml);
$opt = array( 'resource' => 'products' );
$opt['postXml'] = $xml->asXML();
$xml = $ps->add( $opt );

I can not find issue

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