joshmcarthur / spree-import-products

A Spree extension to allow users to batch upload Products from a CSV file using Delayed Job
http://spreecommerce.com/extensions/103-import-products
BSD 3-Clause "New" or "Revised" License
80 stars 97 forks source link

Spree Import Products

This extension adds product import functionality to Spree, with a bunch of features that give it similar functionality to Shopify's importer.

It's been built to be as simple as possible while still doing it's job, and almost the entire workflow of the script beyond creating products from a CSV file is configurable.

This extension adds a tab to the administration area of Spree, allowing a logged-in user to select and upload a CSV file containing product information. The upload is then placed on queue for processing. Once it has been processed, the user who initiated the job is notified by email that their import has completed.

FEATURES

DELAYED JOB

This gem will require (or will install for you), delayed_job. Once the gem has installed and you have run migrations, you should also run rails generator delayed_job to create the tables that delayed_job requires.

Delayed Job also requires that you run 'workers' in the background to pop jobs off the queue and process them. This setup may seem like extra work, but believe me, it pays off - with this method, users get an immediate confirmation that their import is on it's way, with a confirmation later on with full details - this is much better than the previous method where the actual processing was completed during the request, with no feedback reaching the user until after the import had finished.

Run rake jobs:work to start Delayed Job, and rake jobs:clear to clear all queued jobs. Also see delayed_job's Githut page for info on Capistrano support.

For more information on Delayed Job, and for help getting a worker running, see the Github Project Page

TAXONOMIES

The columns of the CSV that contain taxonomies is configurable. Each of these columns can contain a number of formats that represent different hierarchies of taxonomies.

Examples

CONFIGURATION

All the configuration for this extension is inside the initializer generated when you run rake import_products:install. It's basically a big hash with manual column mappings (If you don't want to use dynamic column mapping), and a bunch of settings that control the workflow of the extension. Take a look at the initializer to see more details on each field.

In most cases, it's unlikely you will need to change defaults, but it's there is you need it.

TODOs

Ttttteeeessssttttiiinnnggg!!

INSTALLATION

  1. Add the gem to your Gemfile, and run bundle install. gem 'import_products', :git => 'git://github.com/joshmcarthur/spree-import-products.git' then bundle install

  2. 'Install' the extension - copy a migration and an initializer. rake import_products:install

  3. Do a db migration. rake db:migrate

  4. Configure the extension to suit your application by changing config variables in config/initializers/import_product_settings.rb

  5. Run application!

ATTRIBUTION

The product import script was based on a simple import script written by Brian Quinn here. I've extended it quite a bit and tweaked it to fit my needs.

Copyright (c) 2010 Josh McArthur, released under the MIT License