This code don't works to set taxons in products using Spree Commerce API. WThe product is returned without taxons. Why?
product_params = {
"product[taxon_ids][]" => taxon_id,
"product[available_on]" => product_available_on
}
post_product_update = client.put("/api/products/#{product_id}", product_params)
The response is ... "taxon_ids": [], ... ( http://pastebin.com/ZJVqRLs8 )
SOLVED: "product[taxon_ids]" => taxon_id OR "product[taxon_ids]" => taxon_id, taxon_id,...
Without seeing the data you sent to spree and the output in the spree logs I can't tell what happened to you but you can add taxons to a products by using product[taxon_ids][]=taxon_id
in your POST parameter.
Here is an example with curl
curl -X POST -d "product[name]=TEST&product[price]=100&product[shipping_category_id]=1&product[taxon_ids][]=14&product[taxon_ids][]=15" -H "X-Spree-Token: TOKEN" http://localhost:3000/api/v1/products
This adds the product to taxon 14 and 15.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.