【问题标题】:How to import categories and images in Volusion using Volusion API in PHP如何使用 PHP 中的 Volusion API 在 Volusion 中导入类别和图像
【发布时间】:2017-03-16 20:22:08
【问题描述】:

实际上,我正在尝试使用 PHP cURL 方法通过 Volusion API 将产品导入我的 volusion 商店,产品已成功插入和更新,但类别和图像存在问题。不插入图像和类别。

当我打开我的管理员时,没有分配类别和图像。直到我手动分配然后它显示在前端。

谁知道请帮帮我。我的代码如下..

  1. 我的 XML 文件..

<?xml version="1.0" encoding="utf-8"?>
    <product>
    <productcode>960BX2SSD1</productcode>
    <upc_code>649528774156</upc_code>
    <productmanufacturer>Crucial</productmanufacturer>
    <category>SATA3</category>
    <categorytree></categorytree>
    <productprice>259</productprice>
    <stockstatus>Y</stockstatus>
    <productweight>0.25</productweight>
    <length>0</length>
    <width>0</width>
    <height>0</height>
    <photo_alttext>960BX2SSD1.JPG</photo_alttext>
    <photourl>http://www.malabs.com/i/960BX2SSD1.JPG</photourl>
    <productdescription>&lt;p&gt;&lt;b&gt;SpecificationS&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Mfr Part Number:&lt;/strong&gt; CT960BX200SSD1&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Capacity:&lt;/strong&gt; 960 GB&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Form Factor:&lt;/strong&gt;;</productdescription>
  </product>
  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://xxxxxxxxxxxxx/net/WebService.aspx?Login=xxxxxxxxxxxxx&EncryptedPassword=xxxxxxxxxxx&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;

?>

图片和类别丢失的错误在哪里。

【问题讨论】:

    标签: php xml api curl volusion


    【解决方案1】:

    根据 Volusion 文档,category、categorytree 和 photourl 是虚拟列,无法导入。

    它确实可以使用 CSV 导入,但它不受官方支持。

    我以前从未使用过它,但如果您的类别已经存在于管理中,并且您正在尝试将新产品分配给这些类别,请查看此文档:

    https://support.volusion.com/hc/en-us/articles/208850308-Product-Management-Categories-Products-Link-Developer-

    我更喜欢使用 CSV 导入方法。您不限于每笔交易 100 条记录,您可以插入/更新虚拟字段,如类别 ID 列表。我从我使用的任何后端系统开始,然后动态生成一个 CSV 文件。

    【讨论】:

    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多