My experience with Spree Commerce Product Import using Datashift Spree

Overview

Recently we worked on re-platforming an E-commerce store that we wanted to move to SpreeCommerce to expand their offering & to cater to existing customers better.

As we analysed their ambitious requirements and the desire to launch in a very short period of time, we evaluated existing Spree Commerce extensions that we could use to get work done in the shortest possible period of time.

One big task in the migration, was moving over their existing product catalog to SpreeCommerce.

Our search for an already proven solution for this led us to datashift_spree which looked very promising. datashiftspree is a part of datashift which is a set of tools which help import and export from generic Ruby on Rails application. Datashift has very well defined conventions across representation of data in various cases.

The Run

Warmup

As we started evaluating datashift_spree for the capabilities it mentions, we started seeing some roadblocks as with any integration. Thankfully the roadblaocks were code-critical which we are most comfortable dealing with :)

Just to mention few:

Spree Product Import Usecases

  • Dummy Run helps to find & fix errors without corrupting database with invalid values
  • In case of errors, a detailed report of what/when/how related to steps execution is invaluable for the developer and operations guy for the confidence in import process and its correctness.
  • A uniform convention for data representation catering to different usecases makes the api/changes intuitive for not documented cases and help extend with minimum effort.

Dev Setup with updated branches on Github forks

  • Though above is tested with above setup, it should work on latest ruby and latest Spree 3.0.x version
    • Let us know any difficulties in comments
  • To see in live action without much effort
  • Heroku Demo with Sample CSV file Import
    • Find Product Import tab under Products in Left Sidebar
    • Admin Username: pikender@vinsol.com
    • Admin Password: vinsol
  • Product Import with No Variants

    • After setting up datashift_spree and Spree store locally using Dev Setup with updated branches on Github forks
    • You get access to the enhanced capabilities as exposed in commandline
    • CSV Format
      • Add the product attributes like sku, price, name, description, available_on, cost_price, shipping_category
      • A special column name “Images” will help you add images to product
      • You can provide both a local path accessible while import or an image url
    • Import Command
      • RAILS_ENV=datashift bundle exec thor datashift_spree:load:products -v -i /path/to/csv_file
      • Don’t forget to change RAILS_ENV as applicable and check the path to csv file
    • Output
      • Consolidated Report of CSV rows to be processed, stored in database, with errors and high level errors for failed records
      • Detailed Processing log can be referred in Rails log file

    Product Import with Variants and Product Attributes Default in Variants

    • CSV Format
      • Product Attibutes as mentioned in above case should be present and to make variants, we need to define option_type/option_values as applicable to variant
      • Add variants column in csv and define variants as explained here
    • Import Command
      • No change in import command :)
      • RAILS_ENV=datashift bundle exec thor datashift_spree:load:products -v -i /path/to/csv_file
    • Output
      • Consolidated Report of CSV rows to be processed, stored in database, with errors and high level errors for failed records
      • Detailed Processing log can be referred in Rails log file which will show creation of variants along with product and master both

    Product Import with Variants and overriding Product Attributes Default in Variants

    • CSV Format
      • Variants attributes can be override using special csv columns as supported by datashift_spree which are self-explanatory
      • “variant_sku”,”variant_cost_price”,”variant_price”,”variant_images”,”stock_items
      • It requires to match number of variants to be exactly same as the overriding values above
      • If there are 5 variants to be created, each column above should provide 5 values separated by |
    • Import Command
      • No change in import command :)
      • RAILS_ENV=datashift bundle exec thor datashift_spree:load:products -v -i /path/to/csv_file
    • Output
      • Consolidated Report of CSV rows to be processed, stored in database, with errors and high level errors for failed records
      • Detailed Processing log can be referred in Rails log file

    Further Enhancements

    • Product Import from Shopify Export CSV
    • Upgrade datashift_spree to be compatible with latest datashift version
    • Spree Order Import from CSV

    We are always trying to meet Business time-to-market requirement with the technical challenges and bridge the gap to be narrower and narrower :)

    Checkout Launch Your Store in One Day to not miss the edge.

    Tagged as:

    One thought on “My experience with Spree Commerce Product Import using Datashift Spree

    1. I use the gem and the csv is as follow:
      SKU,Name,Description,Available On, Price,Tax Category,ShippingCategory,CostPrice,Variants,variant_sku,variant_price,variant_cost_price,product_properties,Taxons,Taxons,Taxons,stock_items,Images,variant_images
      PIKS-005,Demo Excel Load via Jruby,less blah,03/10/16,100,Sales Tax,medium,30,mime_type:jpeg;print_type:black_white,1001,80,20,test_pp_003,Paintings,Oils,Paintings>Nature>Landscape,Delhi:5,https://github.com/autotelik/datashift_spree/raw/master/spec/fixtures/images/DEMO_001_ror_bag.jpeg,https://github.com/autotelik/datashift_spree/raw/master/spec/fixtures/images/DEMO_001_ror_bag.jpeg
      Everything is ok but the Variants didn’t create.I don’t konw what happen.

    Leave a Reply

    Your email address will not be published. Required fields are marked *