Comments (8)
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)
https://github.com/autotelik/datashift/wiki/Walkthroughs
from datashift_spree.
from datashift_spree.
Just to confirm - to create a basic Product, you only need to set the Price field
i.e Add a price column and run with datashift:import:excel with --force price
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
Prices are now stored in a separate table, called
spree_prices
. This table tracks the variant, the price amount, and the currency. This allows for variants to have different prices in different currencies.
from datashift_spree.
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)
from datashift_spree.
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) ?
from datashift_spree.
t datashift:import:excel -i /tmp/product.xls -m Spree::Product --force price
t is short for thor?
from datashift_spree.
t is just my alias for bundle exec thor
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
from datashift_spree.
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 ?
from datashift_spree.
Related Issues (20)
- Spree verison 3.0.4 HOT 7
- Feature: spree_related_products support HOT 2
- No Thor commands available HOT 5
- #<NoMethodError: undefined method `stock_location_name=' for #<Spree::Product:0x00000007ecd9a0>> HOT 2
- change count_on_hand in templates to stock_items
- master price is reset if using variants
- Product assigned to every parent taxonomy
- thor datashift_spree:load:products fails to render values from xls formulas HOT 1
- Paperclip not working for spree 3? HOT 6
- Error to upload images using datashift_spree:load:images HOT 3
- how to upload order and users HOT 1
- Products price get a trailing zero in import
- Failed to import supplier_id (spree_drop_ship) HOT 6
- uninitialized constant DataShift::CsvLoading (NameError) HOT 3
- can't attach images on product update HOT 5
- ERROR: "thor csv" was called with arguments ["-i,", "-m,"] Usage: "thor datashift:import:csv -i, --input=INPUT -m, --model=MODEL" HOT 9
- uninitialized constant DataShift::Spree HOT 1
- Failed to import Products. Error: undefined method `type_cast_from_database' HOT 10
- Variants are not updated with variant SKU
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datashift_spree.