如何在Volusion中使用PHP中的Volusion API导入类别和图像 [英] How to import categories and images in Volusion using Volusion API in PHP

查看:208
本文介绍了如何在Volusion中使用PHP中的Volusion API导入类别和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,我试图通过使用PHP cURL方法通过Volusion API将产品导入我的监控存储,产品插入和更新成功,但类别和图像有问题。图像和类别未插入。



当我打开我的管理员时,不会分配类别和图片。直到我通过手动分配,然后它显示在前端。



任何人都知道,请帮助我。我的代码如下..


  1. 我的XML文件..

 <?xml version =1.0encoding =utf-8?& < product> < productcode> 960BX2SSD1< / productcode> < upc_code> 649528774156< / upc_code> <产品制造商> Crucial< /产品制造> < 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;< / b& gt;& lt; / p& gt;< ul& li& gt;& lt; strong& gt;制造商零件编号:& lt; / strong& gt; CT960BX200SSD1& lt; / li& gt;& lt; li& gt;& lt; strong& gt; Capacity:& lt; / strong& 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);

//创建要发布到Webservice的Xml

$ 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;


//创建标题

//发布并返回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);

//检查错误
if(curl_errno($ ch)){

print curl_error($ ch);
} else {

curl_close($ ch);
}

//显示浏览器返回的Xml

echo $ data;

?>

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



类别,categorytree和photourl是虚拟列,无法导入。 >它使用CSV导入工作,但它不受官方支持。



我从来没有使用它,但如果你的类别已经存在于管理员,请尝试将新产品分配给这些类别,请查看以下文档:



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



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


Actually i am trying to import products to my volusion store via Volusion API using PHP cURL method, the products are insert and update successfully but there is an issues with category and images. images and categories are not inserted.

When i open my admin the categories and images are not assign. Untill i assign by manual then it show on front end.

Anyone knows please help me. My code as under..

  1. My XML file..

<?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. My PHP Script

<?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;

?>

Where is the mistake that images and categories are missing.

解决方案

category, categorytree and photourl are virtual columns and can't be imported, according to the Volusion documentation.

It does work using a CSV import, however it's not officially supported.

I've never used it before, but if your categories already exist in the admin and you're trying to assign new products to these categories, check out this documentation:

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

I prefer to use the CSV import method. You're not limited to 100 records per transaction and you can insert/update the virtual fields like a list of category IDs. I start with whatever backend system I'm using, then dynamically generate a CSV file.

这篇关于如何在Volusion中使用PHP中的Volusion API导入类别和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆