2015-01-14 45 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