Search code examples
phpxmlapivolusion

Add product and category association in Volusion through Volusion API


I am trying to add products to the Volusion store using the XML API. I have found the following page which outlines how to associate products with categories and I am finding that it is confusing me.

On this page it states that only two columns are required a ProductID and a CategoryID.

http://support.volusion.com/article/product-management-categories-products-link-developer

However I have found that when I try to export my Products table they do not have an ID column. The unique constraint on that table is based on the ProductCode column.

With that said I did an export of the Categories_Products_Link table and it gave me 3 columns. ID, CategoryID and Auto_Maintenance_Column.

As you can see this does not even line-up with the page that states ProductId is a column.

So I have to ask is the column name ID or ProductID? Also when I did the export I noticed numerical id's in the ID column and NOT ProductCodes so i would wonder what data I should send through as the ProductID?


Solution

  • To assign products to categories using the API with XML data you will have to send a POST request to the API using the following format.

    <?xml version=\"1.0\" encoding=\"utf-8\" ?>
        <xmldata>
        <Categories_Products_Link>
            <CategoryID>108</CategoryID>
            <ProductID>37606</ProductID>
        </Categories_Products_Link>
    </xmldata>
    

    See this for more info...

    https://support.volusion.com/article/product-management-categories-products-link-developer

    You would use your API URL with credentials and remember to use the correct import mode. I used Insert-Update shown below but your should use whatever is appropriate for your needs.

    http://www.yourwebsite.com/net/[email protected] &EncryptedPassword=AA3312590F0B4577E9C660436C7A5244649352B277A557FC87990E6C0CF3789A&Import=Insert-Update
    

    See this for more info...

    http://support.volusion.com/article/api-integration-introduction-developer

    The ProductID is not the product code and not the ID column in the Categories Products Link export. To get each product's ProductID you could run and SQL query like so.

    SELECT Products_Joined.ProductCode, Products_Joined.ProductID FROM Products_Joined WITH (NOLOCK) ORDER BY Products_Joined.ProductCode
    

    Don't forget to send the headers with the POST request

    "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
    "Content-Action", "Volusion_API"