-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how do i generate compatible csv files #69
Comments
Hi ... there is a helper : thor datashift:generate:csv -m, --model=MODEL -r, --result=RESULT That will generate a template file with the headers of the model. So you can generate this for Spree::Product Also, there is equivalent cli to generate Excel instead of CSV. Then you can take you data from another system, and place it in the right columns for Spree This may help (unfortunately I have not worked with Spree for a while so may need tweaking for latest versions) |
AFAIK that is for variants. to load a base product, you need to specify a price column
Spree is a complicated data model, price is actually on the Master Variant not the Product table
hence why it might not be auto generated
Also means when you run the import, you have to tell datashift to process the price method
even though it is not on the product model (its a delegated method) using --force
t datashift:import:excel -i /tmp/product.xls -m Spree::Product --force price
my albums : http://aqwan.bandcamp.com
free stream : http://soundcloud.com/aqwan
On Thursday, 14 June 2018, 07:57:27 CEST, mices <notifications@github.com> wrote:
What about spree prices being a separate table?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just to confirm - to create a basic Product, you only need to set the Price field As I mentioned the force is required because price is a method delegated from the master Variant so it does not show up in normal Rails/Ruby reflection methods You can then setup complex variants and pricing through GUI or a custom script
|
FYI - was playing around in console and this is a way to create the complex Prices product.master.prices.create(currency: "GBP", amount: "2.0", variant: product.master) |
By what magic will currency, amount and variant insert into spree_prices ? datashift is know to do this from the model name Spree::Product (besides --force price) ? |
t datashift:import:excel -i /tmp/product.xls -m Spree::Product --force price t is short for thor? |
t is just my alias for datashift uses active record reflection to find all the available columns and associations on a model. the issue with Spree is it is very complex data model and Product has many delegated methods, down to Variant. these do not show up in the reflections so datashift thinks it cannot use an incoming file column called 'price' the force flag tells datashift that even though it will find no matching Price attribute on Product itself, it is still possible to call product.price i.e product has a price method that does not show up in the reflection. if anyone know a way to get round this and can guide me to a way to discover delegated methods on a Rails model that would be awesome but for now the force flag is a way to inform datashift to attempt to call these methods |
Do you recommend using that method, with datashift using the active record associations or generate separate templates for every model/table for simplicity and certainty's sake ? |
Suggested use is to import csv files created by what?
The text was updated successfully, but these errors were encountered: