Ruby on Rails Tuesday, June 12, 2018

Datashift has template generation for any active record model to csv or excel, for example to create a csv template for a Spree product :

thor  datashift:generate:csv -m Spree::Product --result /tmp/spree_products.csv



You can also export the headers with data via datashift:export:csv


$ more /tmp/spree_products.csv

id,name,description,available_on,deleted_at,slug,meta_description,meta_keywords,tax_category_id,shipping_category_id,created_at,updated_at,promotionable,meta_title,discontinue_on


This gives the required columns into Spree. You can copy the data from your export into the correct Spree fields, the final file can then be imported  via

thor datashift:import:csv -i /tmp/spree_products.csv -m Spree::Product



N.B Spree data model and requirements are complex, simple import may not be enough, you may need to write a few helpers or extend  datashift:import, the README and Wiki are quite extensive

cheers
tom 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5a9cfa09-8fb1-4246-85f3-d6f4f81c9ae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment