Import Products

I’ve used this combination of model/controller/script to add product import functionality to a couple of projects now.
It’s a fairly simple (but easy to extend), drop-in Spree extension that adds an interface to the Administration area that allows a user to select and upload a CSV file containing information on products.

The script portion of this extension then reads the file, creating products with associated information, and
finding, attaching and saving images and taxonomies to the product object.

The extension closely resembles Shopify’s product importer in the functionality provided - Delayed Job is used to enable large imports to run in the background, with no user interaction necessary. Product images can be attached by either specifying a location or disk or a URL, and nested levels of taxonomies are supported.



Comments

Chris Simpson said on December 30, 2010:

Just a couple of small bugs I found in product_import.rb Update the following to: Line 43 : product_information[:description] = row[columns['Description']] Line 129 : master_taxon = Taxonomy.find_by_name(taxon_name) I haven't tested with images yet... but with those corrections, the import for Description and Category will work properly. Thanks for the product import tool... It's very useful. Tested on 0.50.x as well.

Chris Simpson said on December 30, 2010:

Scratch that change on Line 129. I will identify and correct the bugs and post it shortly.

Chris Simpson said on December 30, 2010:

You just have to make sure that you have a "Category" taxonomy, and I have verified that the images work properly. However, you need to correct import_product_settings.rb to reflect the proper path. PRODUCT_IMAGE_PATH = "#{Rails.root}/lib/etc/product_data/product-images/"

Josh McArthur said on January 31, 2011:

Hi @Chris, I'm halfway through adding delayed_job to this extension, since I found that many imports can take quite a long time - I'll take a look at a nicer way to handle the necessary configuration while I finish this off. Of course if you would like to contribute, feel free to fork it on github, and send me a pull request!

Login to Comment.

This project is maintained by a core team of developers and is freely available for commercial use under the terms of the New BSD License.