Is there any way of associating taxons and products throught the API?

Skip to first unread message

Damian Pereira

Jan 25, 2018, 10:17:05 PM1/25/18
to Spree
I'm trying to import 10.000 products into a spree store, my idea was to run an external script while the server is running, and loading every product with a POST to /api/v1/products.

I can also edit product_properties and option_types/values, but I can't find how to associate an existing taxon with a product through the REST api, am I missing anything?

Should I rather do the import with a rake task instead of using the REST API?

Mike Faber

Jan 26, 2018, 10:06:32 AM1/26/18
Hey Damian, 
Thanks for your question.

Please find an answer below, in the meantime I'd like to invite you and everyone else in the Spree community to join Spree Slack channels - a group chat where you can talk to Spree developers and users. We've got over 2200 people there already. 

Here's where you can sign up:

As per your question, our Spree dev says:

You can pass attribute `taxon_ids` as array when doing POST. The same rule applies to `option_type_ids`.
Permitted attributes for products are: 
      :name, :description, :available_on, :discontinue_on, :permalink, :meta_description, :meta_keywords, :price, :sku, :deleted_at, :prototype_id, :option_values_hash, :weight, :height, :width, :depth, :shipping_category_id, :tax_category_id, :cost_currency, :cost_price, option_type_ids: [], taxon_ids: []

See you on Spree slack: :-)

Best Regards,

Michal Faber / 
Spree Evangelist / Spark Solutions COO

Spree open source in 2018 - take a peek into the future:

Spark Solutions Sp. z o.o. 

We are your Ruby on Rails & Spree Commerce Developers 

Contact us and let's talk via Skype or Google Hangouts

Reply all
Reply to author
0 new messages