| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Using API to add products AND attributes | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Using API to add products AND attributes
I've been integrating our retail solution to X-Cart 5 using the API.
I've found that this constructed URL creates a product for X-Cart: https://mysite.com/xcart-5/xcart/admin.php?target=RESTAPI&_key=my-5-xcart-api&_path=product/0&_method=post&model[sku]=990e90e&model[enabled]=1&model[freeShip]=FALSE&model[price]=25&model[salePriceValue]=&model[participateSale]=0&model[inventory][amount]=6&model[translations][0][code]=en&model[translations][0][name]=A%20Tasty%20Merlot%20&model[translations][0][briefDescription]=One%20of%20the%20bests&model[translations][0][description]=It%27s%20really%20good%2E%20 But does anyone know how to construct a URL that also adds the attributes (Like different sizes and colors)? Thanks, Chris |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Using API to add products AND attributes
Hello Chris,
You may use the developer tools built into your browser to check what parameters are sent to the server when you add a product with options. The actual URL format depends on your attributes. Also you may look into using the REST API module: https://www.x-cart.com/extensions/addons/rest-api.html
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#3
|
|||||||
|
|||||||
Re: Using API to add products AND attributes
Than you for answering. I am using the rest api and was hoping you had an example of how the url might be constructed WITH attributes. As you can see, my example is using the rest api and is constructed to add a product.
|
|||||||
#4
|
|||||||
|
|||||||
Re: Using API to add products AND attributes
I tried using Chrome's developer tools but am not seeing any way to see what is being sent to X-Cart.
Do you know if anyone is using the API in 5 to add attributes to products? |
|||||||
#5
|
|||||||||
|
|||||||||
Re: Using API to add products AND attributes
Hello,
I think it is impossible to construct a single URL that would add a product with attributes. You should use several API requests and a) add the product b) add attributes c) link attributes with the product.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#6
|
|||||||
|
|||||||
Re: Using API to add products AND attributes
Ok... I can accept that.
So, do you have any examples of what the URLs would have to look like to add an attribute for a product that has been uploaded? Thanks. |
|||||||
#7
|
|||||||||
|
|||||||||
Re: Using API to add products AND attributes
It depends on the attributes and whether you have these attributes in the database, or no.
Here are tables that X-Cart 5 uses to store attributes: - xc_attributes - stores the list of all available attributes and their identifiers - xc_attribute_translations - stores names of attributes, linked to the xc_attributes table - xc_attribute_values_text - links products with values for their text attributes - xc_attribute_values_text_translations - stores the actual values for text attributes, linked to xc_attribute_values_text - xc_attribute_values_сheckbox - links products with values for their checkbox attributes - xc_attribute_options - links regular attributes (the ones that look as a select box) with identifiers of possible values for these attributes - xc_attribute_option_translations - stores actual text names for possible values of regular attributes, links to xc_attribute_options - xc_attribute_values_select - links products with regular attributes and values selected for these attributes for these products (xc_attribute_options table) If you use attribute groups, you may need to update extra tables. So, you should update/create records in these tables by using a set of subsequent request. You can find an example of doing a similar request to link an existing product with an existing category here: http://kb.x-cart.com/display/XDD/REST+API+documentation#RESTAPIdocumentation-Assigningaproducttoacategory It inserts a new link between xc_products and xc_categories table into the xc_product_categories table. You should do a similar thing for the tables that I listed above.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|