Per inserire un prodotto all'interno dell'ecommerce è necessario generare un feed xml nel seguente formato:
Source
<urn:products xsi:type="urn:Item">
<product>
<groupUID xsi:type="xsd:integer">30</groupUID>
<category xsi:type="xsd:string">DONNA#SCARPE</category>
<brand xsi:type="xsd:string">Acme Inc.</brand>
<title xsi:type="xsd:string">Titolo del prodotto di esempio</title>
<facebookenable>1</facebookenable>
<description xsi:type="xsd:string">
<![CDATA[<p>Descrizione del prodotto, anche in html</p>]]>
</description>
<taxable xsi:type="xsd:integer">0</taxable>
<quantity xsi:type="xsd:integer">10</quantity>
<price xsi:type="xsd:float">259.00</price>
<discount xsi:type="xsd:integer">10</discount>
<weight xsi:type="xsd:integer">1</weight>
<volume>
<w xsi:type="xsd:integer">15</w>
<h xsi:type="xsd:integer">30</h>
<z xsi:type="xsd:integer">100</z>
</volume>
<highview xsi:type="xsd:integer">0</highview>
<sku xsi:type="xsd:string">TRACK_19aBN</sku>
<images>
<image xsi:type="xsd:string">http://domain.tld/products/acme-inc/00001.jpg</image>
<image xsi:type="xsd:string">http://domain.tld/products/acme-inc/00002.jpg</image>
<image xsi:type="xsd:string">http://domain.tld/products/acme-inc/00003.jpg</image>
<image xsi:type="xsd:string">http://domain.tld/products/acme-inc/00004.jpg</image>
</images>
<var>
<variation>
<var_composite>
<key xsi:type="xsd:string">37</key>
<count xsi:type="xsd:integer">2</count>
<price xsi:type="xsd:float">0</price>
<sku xsi:type="xsd:string">CRS0025_NERO_37</sku>
</var_composite>
<var_composite>
<key xsi:type="xsd:string">38</key>
<count xsi:type="xsd:integer">1</count>
<price xsi:type="xsd:float">0</price>
<sku xsi:type="xsd:string">CRS0025_NERO_38</sku>
</var_composite>
</variation>
<var_key>
<var_name xsi:type="xsd:string">Taglia</var_name>
<var_value>
<value xsi:type="xsd:string">37</value>
<value xsi:type="xsd:string">38</value>
<value xsi:type="xsd:string">39</value>
</var_value>
</var_key>
</var>
</product>
</urn:products>
All'interno del tag <urn:products> è possibile inserire più feed articolo.
Nota: Il codice articolo "SKU" è la chiave primaria per il prodotto. Ogni aggiornamento verrà eseguito in base al codice articolo.
GroupUID
ID dello store in cui aggiornare i prodotti.
Tasse
Il tag <taxable> identifica se le tasse sono incluse nel prezzo del prodotto oppure escluse (0 => Tasse incluse nel prezzo; 1 => Tasse escluse).
Sconto Articolo
Il tag <discount> identifica se al prodotto deve essere applicato uno sconto prima della visualizzazione.
Il campo accetta solamente numeri interi; se impostato a 0 nessuno sconto verrà applicato in fase di visualizzazione.
Categorie
Inserire l'albero delle categorie separato da #; nel caso l'albero delle categorie non fosse presente verrà creato.
Dimensioni
Le dimensioni inserite nel feed xml si riferiscono all'imballaggio del prodotto; vengono utilizzate per il calcolo delle spese di spedizione (W => Lunghezza H => Altezza Z => Profondità).
Varianti
In caso di varianti, la quantità mostrata ed acquistabile da parte dei clienti è impostata nel tag <count> all'interno della struttura <var_composite>; di conseguenza il campo <quantity> sarà ignorato.
Qualora il prodotto non prevedesse varianti, il tag <var> e tutto il suo contenuto potrà essere omesso dal feed e la quantità disponibile del prodotto sarà gestita dal tag <quantity>.
PHP
<?
$xml_params = file_get_contents('products_feed.xml');
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache"
);
$auth_user = 'YourEmail';
$auth_password = 'YourPassword';
/** PRECHECK **/
if ($auth_user == '' || $auth_password == '') {
throw new Exception('No Auth key found');
}
$url = 'http://ws.storeden.com/external/postproduct';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0) ;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'StoredenExternalApi');
curl_setopt($ch, CURLOPT_USERPWD, $auth_user.":".$auth_password);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$str_result = curl_exec($ch);
curl_close($ch);
?>
CURL
Coming soon! Una volta completato il caricamento del feed xml il sistema processerà il feed in background.
Commenti