-
-
Save basilkhan05/229364e318b614c9c08d798821bf2482 to your computer and use it in GitHub Desktop.
Download Shopify product image data using Glassbox
This file contains 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 "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', 'image URL'] | |
all_products.flatten.each do |product| | |
product['images'].each do |image| | |
csv_data << [ | |
product['title'], | |
product['handle'], | |
image['src'] | |
] | |
end | |
end | |
csv_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment