Skip to content

spree-contrib/spree_shopify_importer

Repository files navigation

Build Status Code Climate Test Coverage

Spree Shopify Importer

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!

Installation

  1. Add this extension to your Gemfile with this:
gem 'spree_shopify_importer', github: 'spree-contrib/spree_shopify_importer'
gem 'spree_address_book', github: 'spree-contrib/spree_address_book'
gem 'spree_auth_devise', '~> 3.3'
  1. Install the gem using Bundler:
bundle install
  1. Copy & run migrations:
bundle exec rails g spree_shopify_importer:install
  1. Restart your server:

If your server was running, restart it so that it can find the assets properly.

  1. Setup credentials and change default values if needed.

Getting Started

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.

Default values

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'

Import

Currently, you need to have access to the console to start the import.

  1. 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'
      }
    }

Import Model

  1. SpreeShopifyImporter::DataFeed - this model contains copy of JSON imported from shopify and association to spree object.

Import Services

Import services are divided into four main parts. Each of them could be customized.

  1. Data Fetchers are services which are fetching products, users, orders and collections from Shopify.

  2. Importers are services which are saving Shopify data feeds (as shadow copy of import), and starting a create or update action for spree object.

  3. 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.

  4. Data Parsers are services which are changing Shopify data to spree data.

Testing

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'

Contributing

We welcome new pull requests!

License

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.

About Spark Solutions

Spark Solutions

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.

About

Migrate your Shopify store to Spree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages