如何通过API将多张图片上传到Volusion

时间:2015-01-14 21:25:22

标签: ruby-on-rails xml httparty volusion

这是我的Volusion项目插入方法,它依赖于用于rails的HTTParty gem。它适用于发布没有照片的项目,并使用<PhotoURL_Large><PhotoURL_Small> XML标记发布包含单张照片的项目。

def self.post_volusion_item(hide_product, product_code, product_name, product_description, availability, custom_field1, custom_field2, enable_options_inv_control, free_shipping_item, height, length, width, metatag_description, metatag_title, photo_alt_text, photo_xml, product_category, product_price, product_weight, metatag_keywords)
  encrypted_password = ENV['VOLUSION_PASSWORD']
  post_url = "https://WEBSITE-HERE/net/WebService.aspx?Login=LOGIN-HERE&EncryptedPassword=#{encrypted_password}&Import=Insert"
  body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Volusion_API><Products><HideProduct>#{hide_product}</HideProduct><ProductCode>#{product_code}</ProductCode><ProductName>#{product_name}</ProductName><ProductDescription>#{product_description}</ProductDescription><Availability>#{availability}</Availability><CustomField1>#{custom_field1}</CustomField1><CustomField2>#{custom_field2}</CustomField2><EnableOptions_InventoryControl>#{enable_options_inv_control}</EnableOptions_InventoryControl><FreeShippingItem>#{free_shipping_item}</FreeShippingItem><Height>#{height}</Height><Length>#{length}</Length><Width>#{width}</Width><METATAG_Description>#{metatag_description}</METATAG_Description><METATAG_Title>#{metatag_title}</METATAG_Title><Photo_AltText>#{photo_alt_text}</Photo_AltText><PhotoURL_Large>#{photo_url_large}</PhotoURL_Large><PhotoURL_Small>#{photo_url_small}</PhotoURL_Small><ProductCategory>#{product_category}</ProductCategory><ProductPrice>#{product_price}</ProductPrice><ProductWeight>#{product_weight}</ProductWeight><METATAG_Keywords>#{metatag_keywords}</METATAG_Keywords></Products></Volusion_API>"

  post(post_url, body: body)
end

我找不到任何提供项目中包含多张照片的示例的文档。我试过重复这些电话。示例:<PhotoURL_Large>img1</PhotoURL_Large><PhotoURL_Small>img1</PhotoURL_Small><PhotoURL_Large>img2</PhotoURL_Large><PhotoURL_Small>img2</PhotoURL_Small>

这导致没有图片上传。

我意识到PhotoURL与该项目照片的网址无关,但只与Volusion的添加项目表单中的数据相关联。

有人能指出我正确的方向来访问真实的照片网址吗?

1 个答案:

答案 0 :(得分:0)

在Volusion中,PhotoURL_Small和PhotoURL_Large是可以指向内部或外部位置的备用图像URL。 Volusion仅为每个产品代码提供一个,产品代码将用于代替任何加载的图像。因此,如果您填充该产品的上述两个字段中的任何一个,它将使用该URL代替通过图像管理器上传的任何图像或通过FTP直接上传的任何图像。软件中没有提供额外的PhotoURL_Small和PhotoURL_Large图像。

这是对图像文件结构的一个很好的解释。

Image structure