如何使用 Volusion API 在 Volusion 中添加和更新类别

How to add and update categories in Volusion using Volusion API

实际上我有一家商店,我正在将产品导入我的商店,所有产品数据都插入和更新良好,但唯一的类别 ID 没有插入和更新。

  1. 这是我的 XML 代码,名称为 dataPro.txt。

<Products_Joined>
  <productcode>3710_012T</productcode> 
  <vendor_partno>EAH5450SILENT/DI/1GD3(LP)</vendor_partno> 
  <productname>Test Product TA</productname> 
  <hideproduct>N</hideproduct> 
  <stockstatus>20</stockstatus> 
  <lastmodified>1/5/2016 10:25:00 AM</lastmodified>  
  <lastmodby>2</lastmodby> 
  <productweight>0.9</productweight> 
  <productprice>100</productprice> 
  <productmanufacturer>ASUS TeK</productmanufacturer> 
  <vendor_price>32.69</vendor_price> 
  <numproductssharingstock>0</numproductssharingstock> 
  <categoryids>107</categoryids> 
  <producturl>http://tebkq.mvlce.servertrust.com/ProductDetails.asp?ProductCode=3710_012T</producturl> 
  <photourl>http://tebkq.mvlce.servertrust.com/v/vspfiles/templates/tlztech/images/3710_012T.gif</photourl> 
  <categorytree>New: Parts and Accessories</categorytree> 
</Products_Joined>

  1. 这是我的 PHP 脚本。

<?php
 $file = file_get_contents('dataPro.txt', true);

//  Create the Xml to POST to the Webservice

    $Xml_to_Send = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
    $Xml_to_Send .= "<Volusion_API>";
//  $Xml_to_Send .= "<!--";
    $Xml_to_Send .= $file;
//  $Xml_to_Send .= "\"\"";
//  $Xml_to_Send .= "-->";
    $Xml_to_Send .= "</Volusion_API>";


$url = "http://mysitedomian/net/WebService.aspx?Login=xxxxxxxxxxx&EncryptedPassword=xxxxxxxxx&Import=Insert-Update";


//  Create the Header   

    //  Post and Return Xml
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $Xml_to_Send); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
    $data = curl_exec($ch);

    //  Check for Errors
    if (curl_errno($ch)){
      
        print curl_error($ch);
    } else {
      
       curl_close($ch);
    }

   //  Display the Xml Returned on the Browser
    
   echo $data;
  
?>

一旦您的产品和类别已经在您的 Volusion 数据库中,请调用 API 并像这样传递 XML:

<xmldata>
  <Categories_Products_Link>
    <CategoryID>10</CategoryID>
    <ProductID>20</ProductID>
  </Categories_Products_Link>
</xmldata>