Last active
December 21, 2015 07:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | order_quantity_min | order_quantity_max | |
---|---|---|---|
32 | 2 | 10 | |
33 | 2 | 10 | |
34 | 2 | 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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