Spree Commerce

Try It Now

- 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!

anju ps said on December 16, 2011:

Hi All I have installed spree import products and followed all the installation steps.Everything went well. I have doubts regarding csv file. Can someone post sample file here . I tried with a csv file containing the following data; "HETOKEXX","Heinz Tomchi Ketchup",100,120,1,2,3,4,"","","","","testing",1 But I got the following error , [Worker(host:ubu1004 pid:8024)] Starting job worker [2011-12-16 18:09:26] [Info] ["Ruby on Rails Ringer T-Shirt", "Ruby on Rails Mug", "Ruby on Rails Tote", "Ruby Baseball Jersey", "Apache Baseball Jersey", "Ruby on Rails Bag", "Ruby on Rails Baseball Jersey", "Ruby on Rails Stein", "Ruby on Rails Jr. Spaghetti"] [2011-12-16 18:09:26] [Info] Importing products for example.csv began at 2011-12-16 18:09:26 +0530 [2011-12-16 18:09:26] [Error] An error occurred during import, please check file and try again. (no implicit conversion from nil to integer) /usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems/spree-import-products-2bcca17f140f/app/models/product_import.rb:65:in `[]'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems/spree-import-products-2bcca17f140f/app/models/product_import.rb:65:in `block in import_data!'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems/spree-import-products-2bcca17f140f/app/models/product_import.rb:41:in `each'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems/spree-import-products-2bcca17f140f/app/models/product_import.rb:41:in `import_data!'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems/spree-import-products-2bcca17f140f/lib/import_products/import_job.rb:14:in `perform'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:87:in `invoke_job'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block (2 levels) in run'\n/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:58:in `timeout'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block in run'\n/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:119:in `run'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:177:in `reserve_and_run_one_job'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:104:in `block in work_off'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `times'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `work_off'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:78:in `block (2 levels) in start'\n/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:77:in `block in start'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `loop'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `start'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.1.4/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'\n/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'\n/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'\n/usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>' [Worker(host:ubu1004 pid:8024)] ImportProducts::ImportJob completed after 3.5671 [Worker(host:ubu1004 pid:8024)] 1 jobs processed at 0.2730 j/s, 0 failed ... Am i doing something wrong? Also after i did rake import_products:install , no file named import_product_settings.rb was created in my rails app location config/initializers/. Or do I need to copy that file from the repository ,https://github.com/joshmcarthur/spree-import-productse/blob/master/config/initializers/import_product_settings.rb ? Thanks in advance,

Login to Comment.

LATEST

Blue theme
by thelet down
aaaa
by tanavat musikachat
TestSpree
by Vasya Semenov
Spree BitPay
by Bitpay Inc
sdfsadfsdafasf
by David Cameron

CREATED BY

Josh McArthur

Github

Version information could not be retrieved.