Skip to content

Instantly share code, notes, and snippets.

@basilkhan05
Last active March 2, 2020 03:05
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 basilkhan05/e4d6558395ddb345fbf9b08585431ff3 to your computer and use it in GitHub Desktop.
Save basilkhan05/e4d6558395ddb345fbf9b08585431ff3 to your computer and use it in GitHub Desktop.
Download shopify store products using Glassbox
require "httparty"
shopify_url = fields["shopify_url"]
page = 1
all_products = []
while true
url = "#{shopify_url}/products.json?page=#{page}"
response = HTTParty.get(url)
products = response["products"]
break unless products.length > 0
all_products << products
page += 1
end
csv_data = []
csv_data << ['Product title', 'handle', 'body html', 'vendor', 'Product type', 'tags']
all_products.flatten.each do |product|
csv_data << [
product['title'],
product['handle'],
product['body_html'],
product['vendor'],
product['product_type'],
product['tags'].join('|'),
]
end
csv_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment