Import .csv into spree

868 views
Skip to first unread message

Adam

unread,
Oct 15, 2009, 1:08:37 PM10/15/09
to Spree
I am working on an e-commerce site that has roughly 700 sku's with
about 15 line items per sku i.e. (size, color, dimension etc) Can I
import this data via excel into the Spree database and if so any tips?

Sean Schofield

unread,
Oct 15, 2009, 1:12:37 PM10/15/09
to spree...@googlegroups.com
If you search the archives you'll find some references to various
scripts (most available as gists.) I'd start there.

Sean

Torsten Rüger

unread,
Oct 16, 2009, 8:28:01 AM10/16/09
to spree...@googlegroups.com
Hello,

I too face the import issue. In fact we are going for a "soft
opening" of the shop and will do small imports at regular intervals.
We have 2000+ products and that's just too much work in one go, all
that typing and pictures .. ..

Anyway, so I have motivation and some skill. Meaning while I've
written plenty software, but only a fraction of it was in ruby.

So from what I've read on the archives, the topic has been raised
often, but not resolved. I've seen Seans response a number of time
but none of those gists. (Those are code snippets on github, in case
there are other newbies reading).

So I'd propose I would write this thing, and co-ordinate if anybody
want to help. Three things would be great:

1 Sean or anyone responsible to say how we best aproach this ? I
could get a github account and start a spree-import repository ? I
read about tab delimited, sounds good. FastCSV also good.
2 Anyone that has usecases, please send them to me (with sample data)
3 If there is existing code out there, please send.

Torsten

Sean Schofield

unread,
Oct 16, 2009, 9:30:23 AM10/16/09
to spree...@googlegroups.com
Paul Callaghan is probably our best guy for bulk upload. There really
is a gist for this (search "gist upload" in the spree-user group.)
Paul wrote up a wiki entry[1] that points to this gist and mentions a
few other tips.

Sean Schofield

---------------------------------------
Rails Dog LLC
5335 Wisconsin Avenue NW
Suite 440
Washington, DC 20015
voice: (301)560-2000
---------------------------------------

[1] http://wiki.github.com/railsdog/spree/developers-tricks-and-tips

Brian Quinn

unread,
Oct 16, 2009, 9:31:32 AM10/16/09
to spree...@googlegroups.com
Here's one of the Gists: http://gist.github.com/31710 

It's very basic rake task but its a start!

William Emerson

unread,
Oct 17, 2009, 3:13:52 PM10/17/09
to spree...@googlegroups.com
I added a gist with the code I use to import Variants. This for a
system that doesn't use the product hierarchy so it only deals with
one table. You can use it to import into any table by changing the
model name and the key name and making sure that the first line in the
import file has the correct field names separated by the delimiter
with the key specified. You don't need all the fields in the table and
they don't need to be a specific order (except the key).

http://gist.github.com/212429

Thank god and James Edward Gray II for fastercsv!

I welcome feedback and improvements. I think having easy, reliable
imports and exports are important to Spree.

Will Emerson

qwan

unread,
Oct 18, 2009, 9:10:43 AM10/18/09
to Spree
My tip would be to use seed_fu - http://github.com/mbleigh/seed-fu -
for loading and reloading the DB .. I've moved all my fixtures to
this and been very happy.

You can create erb templates to populate seed_fu files which can then
be run and rerun into the DB. The README also contains details of
using a csv file.

I have also written a MS Word parser, as some larger HTML prod
descriptions were provided like that ... which saves to clean HTML and
rake tasks can then easily populate the seed_fu template. I will
obviously happily package this up properly for Spree time permitting,
but for time being have put the required template and scripts in a
gist ... git://gist.github.com/212645.git

.. which can be saved to your site extensions and used like this

rake spree:extensions:site:word2html

Converts all MS Word docs in RAILS_ROOT/doc/copy to clean HTML.

rake spree:extensions:site:word2seedfu

Converts all MS Word docs in RAILS_ROOT/doc/copy to seed_fu fixtures.

Cheers
tom




qwan

unread,
Oct 18, 2009, 9:22:04 AM10/18/09
to Spree
p.s that should be http://gist.github.com/212645

and for reference, tool to tidy up html, is HTML Tidy - http://tidy.sourceforge.net

dancinglightning

unread,
Oct 20, 2009, 10:50:17 AM10/20/09
to Spree
Well, thanks everyone. I've lloked at all the stuff and got many goog
ideas and code snippets.

As such none if it fit's 100% but it's a good start and I imported my
first products already.

So I'll get coding now and that'll take a while, but if anyone has
anything more (usecases or technical hints), please feel free to mail
me directly.

Torsten

Reply all
Reply to author
Forward
0 new messages