Importing products from Magento into Spree

Magento is evil. If you're working with its PHP codebase, I'm sorry. After looking for an easier, less dangerous solution, I found Spree. Easy to use, looks half decent out of the box, and built on Ruby on Rails, the slow but easy web framework. And there's a Heroku extension. Awesome.

One problem: The Magento installation had 9000 products, with names, descriptions, SKUs, and other fun attributes. Spree has no built-in import or export function. Do I want to enter all this information manually? No.

After some googling, yahooing, and asking jeeves, I found a Google group discussion, took some of the example code, tailored it to the CSV format of a standard Magento export, and ended up with this hack:
If you don't have the FasterCSV gem installed, install it before running this import script:
gem install fastercsv

Use the Rails runner to run this script so it has access to the database:
script/runner import.rb

and you're done.


  1. Chris Cummings8/02/2011 12:55 AM

    Thanks for posting this. I'm hoping to convince my boss in a few months to let me switch our massive store (29k SKUs) from Magento to Spree. This was a hurdle I wasn't looking forward to dealing with.

  2. Aaron Lifton12/23/2011 9:15 AM

    No problem, glad I was able to help someone out!

  3. Good to know, FasterCSV looks useful. I'm trying to do the same thing but decided to go with datashift_spree. It supports importing images and it allows you set default values if some of the columns are missing. All from the command line.