2015-01-14 42 views
0

这是我的Volusion项目插入方法,它依赖于用于rails的HTTParty gem。它适用于张贴没有照片的项目,并使用<PhotoURL_Large><PhotoURL_Small> XML标签张贴包含单张照片的项目。如何通过API将多张图片上传到Volusion

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的添加物品表单中的数据有关。

有人可以指出我正确的方向访问真正的照片网址为vol items项目?

回答

0

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

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

Image structure

+1

感谢您的解释和文档链接。那么您是否同意,从一个自定义应用程序上传包含多张照片的项目的唯一解决方案是使用API​​调用发布该项目,然后使用正确的文件名将照片FTP到vspfiles/photos? –

+0

你不需要发布任何东西给Volusion。您只需要使用正确的产品代码前缀和后缀上载图像,如前面链接到的文档中所示。如果图像文件名称正确,您的产品将自动显示。这适用于多个备用图像和色板图像以及文档中显示的所有其他图像。 – user357034