The Spree Shopify Importer gem allows you to easily import data from Shopify store to Spree application. It's compatible with Spree 3.2 and above.
Behind-the-scenes, this extension is using Shopify API gem.
Currently, it's in version 0.1.0. It has been tested with thousands of real life orders, but we welcome new pull requests!
- Add this extension to your Gemfile with this:
gem 'spree_shopify_importer', github: 'spark-solutions/spree_shopify_importer'
gem 'spree_address_book', github: 'spree-contrib/spree_address_book'
gem 'spree_auth_devise', '~> 3.3'
- Install the gem using Bundler:
bundle install
- Copy & run migrations:
bundle exec rails g spree_shopify_importer:install
- Restart your server:
If your server was running, restart it so that it can find the assets properly.
- Setup credentials and change default values if needed.
We are recommending using sidekiq for background processing with this stack of gems:
gem 'sidekiq'
gem 'sidekiq-limit_fetch'
gem 'sidekiq-unique-jobs'
We also recommend having a limit 2 for import queue, due to API limit. Default queue name is default but it can be changed in Spree::AppConfiguration under shopify_import_queue key.
All default values are saved in Spree::AppConfiguration
- ShopifyAPI credentials - used for api authorization.
- shopify_api_key - nil
- shopify_password - nil
- shopify_shop_domain - nil
- shopify_token - nil
- Import Rescue Limit - used for retrying API errors, for example API limit hit.
- shopify_rescue_limit - 5
- Import Queue Name
- shopify_import_queue - 'default'
Currently, you need to have access to the console to start the import.
- To start import, in console run:
With default values
SpreeShopifyImporter::InvokerJob.new.import!
or with credentials.
SpreeShopifyImporter::InvokerJob.new(credentials).import!
Where credentials could have two formats:
{
credentials: {
api_key: 'api_key',
password: 'password',
shop_domain: 'shop_domain'
}
}
or
{
credentials: {
token: 'token',
shop_domain: 'shop_domain'
}
}
- SpreeShopifyImporter::DataFeed - this model contains copy of JSON imported from shopify and association to spree object.
Import services are divided into four main parts. Each of them could be customized.
-
Data Fetchers are services which are fetching products, users, orders and collections from Shopify.
-
Importers are services which are saving Shopify data feeds (as shadow copy of import), and starting a create or update action for spree object.
-
Data Savers are services which are saving spree objects, each of them has a parser method which can be overridden to change update/create attributes and associations.
-
Data Parsers are services which are changing Shopify data to spree data.
To run all the tests for the build, clone the repo and run:
bundle exec rake
This will generate a dummy app for testing, run rubocop style checker and rspec tests.
When testing your applications integration with this extension you may use its factories. Simply add this require statement to your spec_helper:
require 'spree_shopify_importer/factories'
We welcome new pull requests!
Spree Shopify Importer is copyright © 2015-2018 Spark Solutions Sp. z o.o.. It is free software, and may be redistributed under the terms specified in the LICENSE file.
Spree Shopify Importer is maintained and funded by Spark Solutions Sp. z o.o. The names and logos are trademarks of Spark Solutions Sp. z o.o.
We are passionate about open source software. We are available for hire.