Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tomkeysers/f60c24d4dcb9aa97ab68c9da21764887 to your computer and use it in GitHub Desktop.

Select an option

Save tomkeysers/f60c24d4dcb9aa97ab68c9da21764887 to your computer and use it in GitHub Desktop.

Revisions

  1. tomkeysers revised this gist Mar 20, 2018. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions bigcartel_to_shopify_csv.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    require 'csv'

    # SET YOUR BIGCARTEL ID HERE
    STORE = 'ugmonk'
    STORE = 'mystorename'

    # SET THE BEST NAME FOR ANY DROP DOWN OPTIONS
    BC_OPTION_NAME = "Size"
    @@ -29,7 +29,7 @@ class Shopify <
    row.title = p.name
    row.body = p.description
    row.vendor = s.name
    row.type = p.categories.first.name
    row.type = p.categories.first ? p.categories.first.name : ""
    row.tags = p.categories.collect{|x| x.name}.join(', ')


    @@ -44,7 +44,7 @@ class Shopify <
    end

    row.price = price
    row.image_src = p.image.url
    row.image_src = p.image ? p.image.url : ""

    #defaults to allow import to shopify
    row.qty = 0
    @@ -75,10 +75,10 @@ class Shopify <
    end

    #additional images
    for i in 1..p.images.length-1 do
    for i in 0..p.images.length-1 do
    img_row = Shopify.new
    img_row.handle = p.permalink
    img_row.image_src = p.images[i].url
    img_row.image_src = p.images[i].url.sub(".jpg", ".jpg?fit=max&h=2000&w=2000").sub(".JPG", ".JPG?fit=max&h=2000&w=2000").sub(".jpeg", ".jpeg?fit=max&h=2000&w=2000")
    rows.push(img_row)
    end

  2. @tonkapark tonkapark created this gist Aug 3, 2011.
    94 changes: 94 additions & 0 deletions bigcartel_to_shopify_csv.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    #script created by Matt Anderson, http://tonkapark.com

    require 'rubygems'
    require 'bigcartel'
    require 'csv'

    # SET YOUR BIGCARTEL ID HERE
    STORE = 'ugmonk'

    # SET THE BEST NAME FOR ANY DROP DOWN OPTIONS
    BC_OPTION_NAME = "Size"

    class Shopify <
    Struct.new(:handle, :title, :body,:vendor,:type,:tags,
    :opt1_name, :opt1_val,
    :opt2_name, :opt2_val,
    :opt3_name, :op3_val,
    :sku,:grams,:inventory_tracker,:qty, :inventory_policy, :fullfillment,
    :price,:compare_at, :requires_shipping, :taxable, :image_src)
    end

    s = BigCartel.store(STORE)

    rows = Array.new

    s.products.each do |p|
    row = Shopify.new
    row.handle = p.permalink
    row.title = p.name
    row.body = p.description
    row.vendor = s.name
    row.type = p.categories.first.name
    row.tags = p.categories.collect{|x| x.name}.join(', ')


    if p.has_default_option
    row.opt1_name = BC_OPTION_NAME
    row.opt1_val = p.option.name
    price = p.option.price
    else
    row.opt1_name = BC_OPTION_NAME
    row.opt1_val = p.options.first.name
    price = p.options.first.price
    end

    row.price = price
    row.image_src = p.image.url

    #defaults to allow import to shopify
    row.qty = 0
    row.inventory_policy = 'deny'
    row.fullfillment = 'manual'
    row.sku = p.id

    rows.push(row)

    #additional variants
    unless p.has_default_option
    for i in 1..p.options.length-1 do
    opt_row = Shopify.new
    opt_row.handle = p.permalink
    opt_row.opt1_name = BC_OPTION_NAME
    opt_row.opt1_val = p.options[i].name
    opt_row.price = p.options[i].price

    #defaults to allow import to shopify
    opt_row.qty = 0
    opt_row.inventory_policy = 'deny'
    opt_row.fullfillment = 'manual'
    opt_row.sku = p.id

    rows.push(opt_row)
    end

    end

    #additional images
    for i in 1..p.images.length-1 do
    img_row = Shopify.new
    img_row.handle = p.permalink
    img_row.image_src = p.images[i].url
    rows.push(img_row)
    end

    end

    file_name = "#{STORE}.csv"
    CSV.open(file_name, 'w') do |csv|
    header_row = ["Handle", "Title", "Body (HTML)", "Vendor", "Type", "Tags", "Option1 Name", "Option1 Value", "Option2 Name", "Option2 Value", "Option3 Name", "Option3 Value", "Variant SKU", "Variant Grams", "Variant Inventory Tracker", "Variant Inventory Qty", "Variant Inventory Policy", "Variant Fulfillment Service", "Variant Price", "Variant Compare At Price", "Variant Requires Shipping", "Variant Taxable", "Image Src"]
    csv << header_row
    rows.each { |p|
    csv << p
    }
    end