Skip to content

Instantly share code, notes, and snippets.

@saranyan
Last active December 21, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saranyan/6274214 to your computer and use it in GitHub Desktop.
Save saranyan/6274214 to your computer and use it in GitHub Desktop.
Update product min_quantity and max_quantity from CSV file using Bigcommerce API
id order_quantity_min order_quantity_max
32 2 10
33 2 10
34 2 10
require 'bigcommerce'
require 'csv'
api = Bigcommerce::Api.new({
:store_url => "https://store-xxx.mybigcommerce.com/",
:username => "admin",
:api_key => "key"
})
header = []
File.foreach('product_data.csv') do |csv_line|
row = CSV.parse(csv_line).first
if header.empty?
header = row.map(&:to_sym)
next
end
row = Hash[header.zip(row)]
api.update_products(row[:id],{:order_quantity_minimum => row[:order_quantity_min], :order_quantity_maximum => row[:order_quantity_max]})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment