Ruby on Rails Friday, June 15, 2018



On Tuesday, June 12, 2018 at 4:47:04 AM UTC-4, qwan wrote:
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 can copy the data from your export into the correct Spree fields"
How would I do that?
 

--
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/6b592661-59d0-4be9-9e63-fba1800f6180%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment