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

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

问题描述

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

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. 我的 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;

?>

缺少图片和类别的错误在哪里.

Where is the mistake that images and categories are missing.

推荐答案

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

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

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

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-

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

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.

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

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