2016-06-24 7 views
1

Ich versuche, ein Produkt in meinen Shopify-Shop mithilfe der Shopify-Produkt-API einzufügen.Produktbild wird nicht in shopify Store eingefügt Über API

Jetzt kann ich die Produktdaten sowie Varianten der Produkte einfügen.

hier ist mein Skript

<?php 

    $name='test product 999'; 
    $group=36; 
    $quantity=20; 
    $price='20.95'; 
    $image = "http://clarks.scene7.com/is/image/clarks/26103666_A"; 

    $url = "https://xxx:[email protected]/admin/products.json"; 

    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_URL, $url); 
    $type = 'POST'; 
    $product = array('title' => utf8_encode($name), 
    'body_html' => utf8_encode($name), 
    'product_type'=> $group, 
    'vendor'=>'abc', 
    'id'=> '999', 
    "tags" => "Emotive, Flash Memory, MP3, Music", 
    "images"=>array  ("src"=>'http://clarks.scene7.com/is/image/clarks/26103666_A'), 
    'variants' => array(
    array('price' => $price, 
     'compare_at_price'=> $price, 
     'sku'=>'123gdjf', 
    'inventory_quantity'=> $quantity, 
    'inventory_management' => 'shopify' 
    ) 
    ) 

    ); 

     $ch = curl_init($url); 
     $data_string = json_encode(array('product'=>$product)); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json', 
    'Content-Length: ' . strlen($data_string)) 
    ); 

    $server_output = curl_exec ($ch); 
    print_r($server_output); 
     curl_close ($ch); 


    ?> 

Es werden keine Bilder speichern nur Daten Produkt speichert. kann mir jemand sagen, wo ich falsch liege. oder was ist falsch in meinem Skript.?

danke

Antwort

0

sorry ..

es sehr kleine Fehler war.

Ich habe Code ersetzt

"images"=>array  ("src"=>'http://clarks.scene7.com/is/image/clarks/26103666_A'), 

Mit

"images"=>array(array ("src"=>'http://clarks.scene7.com/is/image/clarks/26103666_A')), 

Nun meine Bilder speichern

dank