Giter VIP home page Giter VIP logo

spree-import-products's Introduction

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

  • A reasonably opinionated product import model should take the heavy lifting out of batch-importing products.
  • Using things like class_eval, it can be extended or changed to do more, less, or something differently.
  • Using delayed_job, the import is no longer processed when the user uploads the CSV file (Note: this requires the proper installation and configuration of delayed job).
  • Columns are mapped dynamically by default. This means that if you have a SKU column in your CSV file, it will be automatically set as the sku attribute of the Product model.
  • Multiple taxonomies are supported (By default, the importer looks for Brand and Taxonomy). Multiple taxonomy nesting is also supported. (See the 'Taxonomies' area below)
  • Multiple images are supported (By default, the importer looks for Image Main, Image 2, Image 3 and Image 4). Images can be loaded either from disk, or from a publicly-accessible URL.
  • Automatically creating variants is supported out-of-the-box - the importer compares the imported data with already-created products (By default, on the Product's permalink attribute), and creates a variant of that product if it exists already. Custom fields are also supported if dynamic column mapping is enabled - simply having 'Color', 'Size', 'Material' columns in your CSV file for example, will automatically set the relevant custom fields on the variant to the values from the CSV.
  • It now uses the Ruby 1.9.2 standard CSV library (a.k.a FasterCSV).

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

  • Basic taxonomy association for Category: Furniture
  • Multiple taxonomy association for Category: Furniture & Clearance
  • Hierarchy taxonomy association for Category: Furniture > Dining Room > Tables
  • Multiple hierarchy taxonomy association for Category: Furniture > Dining Room > Tables & Clearance > Hot this week

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

spree-import-products's People

Contributors

joshmcarthur avatar jzw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spree-import-products's Issues

deface :insert_after should be :insert_bottom for admin tab

This may be just for 0.70 (since that's the only Spree I've used) however, :insert_after places the "Import Products" tab outside the admin_tabs div, where it should have been added as a new tab inside that div.

I've changed it in my local copy of the source, but I'm new to github so don't know how to submit it back :)

Add Gemfile

Add Gemfile with dependency on delayed_job version greater than 2.1

This is more of a reminder for me, but if someone else wants to do it for me, go right ahead!

uninitialized constant Spree::Calculator (NameError) when i do bundle exec rails g spree_related_products:install

I'm using with ruby 3.0.3 and rails 7
bundle exec rails g spree_related_products:install
/Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/bundler/gems/spree_related_products-3456b108b630/lib/spree_related_products/engine.rb:10:in block in <class:Engine>': uninitialized constant Spree::Calculator (NameError) from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:32:in instance_exec'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:32:in run' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:61:in block in run_initializers'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:228:in block in tsort_each' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:422:in block (2 levels) in each_strongly_connected_component_from' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:431:in each_strongly_connected_component_from'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:421:in block in each_strongly_connected_component_from' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:50:in each'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:50:in tsort_each_child' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:415:in call'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:415:in each_strongly_connected_component_from' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:349:in block in each_strongly_connected_component'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in each' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in call'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:347:in each_strongly_connected_component' from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:226:in tsort_each'
from /Users/muneebsarfraz/.rvm/rubies/ruby-3.0.3/lib/ruby/3.0.0/tsort.rb:205:in tsort_each' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/initializable.rb:60:in run_initializers'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/application.rb:372:in initialize!' from /Users/muneebsarfraz/Projects/vendorhost/config/environment.rb:5:in

'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in require'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/application.rb:348:in require_environment!' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/command/actions.rb:28:in require_environment!'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/command/actions.rb:15:in require_application_and_environment!' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/commands/generate/generate_command.rb:21:in perform'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor/command.rb:27:in run' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor/invocation.rb:127:in invoke_command'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/thor-1.2.1/lib/thor.rb:392:in dispatch' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/command/base.rb:87:in perform'
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/command.rb:48:in invoke' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/railties-7.0.4/lib/rails/commands.rb:18:in '
from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' from /Users/muneebsarfraz/.rvm/gems/ruby-3.0.3/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require'
from bin/rails:4:in `'

Installation error

Hi Josh

I am seeing this error on a fresh install of spree I setup yesterday when I try to install your product import extension (following instructions on the wiki page on GitHub):

ubuntu@ip-10-204-215-97:~/work/geometry_active_wear$ rake import_products:install
rake aborted!
uninitialized constant Spree::ThemeSupport

(See full trace by running task with --trace)
ubuntu@ip-10-204-215-97:~/work/geometry_active_wear$ rake import_products:install --trace
rake aborted!
uninitialized constant Spree::ThemeSupport
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/bundler/gems/spree-import-products-2bcca17f140f/lib/import_products_hooks.rb:1:in <top (required)>' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/bundler/gems/spree-import-products-2bcca17f140f/lib/import_products.rb:2:in<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in require' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in each' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:inblock in require'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in each' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:inrequire'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@geometry_active_wear/gems/bundler-1.1.3/lib/bundler.rb:119:in require' /home/ubuntu/work/geometry_active_wear/config/application.rb:7:in<top (required)>'
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
/home/ubuntu/work/geometry_active_wear/Rakefile:5:in <top (required)>' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:inload'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in load_rakefile' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:501:inraw_load_rakefile'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:82:in block in load_rakefile' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:81:in load_rakefile' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:65:inblock in run'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' /home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:inload'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `

Here are the spree gems I have installed:

spree (1.1.0)
spree_api (1.1.0)
spree_auth (1.1.0)
spree_cmd (1.1.0)
spree_core (1.1.0)
spree_dash (1.1.0)
spree_promo (1.1.0)
spree_sample (1.1.0)
spree_skrill (1.0.2)
spree_usa_epay (1.0.2)

Many thanks

Ben

can't rake import_products:install

When I trying rake import_products:install I get in CLI

INFO: Mirroring assets from /home/sashe/.rvm/gems/ree-1.8.7-2011.03@store/bundler/gems/spree-import-products-b845ab7808a8/lib/tasks/../../db to /home/sashe/Sites/synergy_app/db
NOTE: This extensions uses delayed job - you need to generate additional migrations for this gem by executing `rails generate delayed_job_migrations'
INFO: Mirroring assets from /home/sashe/.rvm/gems/ree-1.8.7-2011.03@store/bundler/gems/spree-import-products-b845ab7808a8/lib/tasks/../../public to /home/sashe/Sites/synergy_app/public
Could not mirror /home/sashe/.rvm/gems/ree-1.8.7-2011.03@store/bundler/gems/spree-import-products-b845ab7808a8/lib/tasks/../../public - entity does not exist

how to solve this problem?

Bundler could not find compatible versions for gem "spree_core".

Hi

I want to install import_products in branch 1_1_x, in my Gemfile I have:

gem 'import_products', :git => 'git://github.com/joshmcarthur/spree-import-products.git', :branch => '1_1_x'

without :branch works, but I need install from branch 1_1_x

after run bundle install and I have the error

Bundler could not find compatible versions for gem "spree_core":
    In snapshot (Gemfile.lock):
        spree_core (1.3.2)

    In Gemfile:
        import_products (>= 0) ruby depends on
            spree_core (~> 1.0.0) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

any tips?

Can`t do rake import_products:install

in my db/migration file
20160405122047_create_product_imports.import_products_engine.rb
20160406083705_add_queue_to_delayed_jobs.rb
20160406111119_create_delayed_jobs.rb
those three files are did not change to green color but in not shown any error or migration pending..
when i run rake import_products:install show this error.....

INFO: Mirroring assets from /usr/local/rvm/gems/ruby-2.2.3/bundler/gems/spree-import-products-2bcca17f140f/lib/tasks/../../db to /home/altius/ramesh/import/db
NOTE: This extensions uses delayed job - you need to generate additional migrations for this gem by executing `rails generate delayed_job_migrations'
altius@uror-10:/ramesh/import$
altius@uror-10:
/ramesh/import$ rails generate delayed_job_migrations
Could not find generator 'delayed_job_migrations'. Maybe you meant 'delayed_job:upgrade', 'delayed_job' or 'delayed_job:active_record'

Please can you help me...
How to resolve this.....

uninitialized constant ImportProducts::Engine::UserMailer (NameError)

I'm installing a fresh 0.70.1 spree and want to include import-products however i'm hitting the following error. I'm still new to Spree (and to some extent Ruby) so any advice you can offer would be much appreciated.

jupiter$ rails g spree:site
/gem-source/spree-import-products/lib/import_products.rb:14:in `activate': uninitialized constant ImportProducts::Engine::UserMailer (NameError)
(stack cut for brevity)

example csv file

Hi,
Would you not mind putting up an example CSV file that has some products in it together with some variants so that I can determine exactly what format the CSV file must look like. Thank you.

Adding Tests

Hi everyone,

I'm adding this issue to ask if anyone is able to help me out to get spree-import-products covered by specs. I've spent the last few weeks trying to get my head around the best way to do the following things:

  1. Testing for multiple versions of Spree: I'm keen to maintain backwards compatibility with Spree, ideally back to the version for which I built this extension (0.30, I believe). The challenges I've faced here include architecting the extension to work with different versions, and, in particular, how to generate some sort of test app that I can test the extension with. Spree's generators for test apps seem to have changed over versions, so it's not a simple command I can run, and different versions seem to have different requirements of the extension.
  2. Writing concise, useful specs that cover the majority of the code base: while I've written RSpec specs before on more than one occasion, I've not yet managed to write specs for an application that I'm happy with in terms of conciseness and usefulness.

So far, I've had a nice strategy suggested to me to use a Versionfile to manage backwards compatibility. This would involve having a branch dedicated to each version of Spree that should be supported. This simplifies generating sandbox Spree apps for running specs against, and code that is specific to one or more versions (Such as deface support).

I would appreciate any offers to either try and get a testing infrastructure set up that myself and others can run specs against, to add specs yourself, to help me out, or generally to offer opinions and advice. I'll continue to monitor and feedback on this issue as I carry on trying to get a testing infrastructure in place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.