Skip to content

Instantly share code, notes, and snippets.

@juque
Created June 29, 2021 07:17
Show Gist options
  • Select an option

  • Save juque/630aa3be67a2f4b87465ff2ecd3ef013 to your computer and use it in GitHub Desktop.

Select an option

Save juque/630aa3be67a2f4b87465ff2ecd3ef013 to your computer and use it in GitHub Desktop.
file = "product_info.csv"
columns = ["slug", "title", "price", "variant_count"]
data = CSV.generate do |csv|
csv << columns
shop.products(status: "all", class: "product").full_set.each do |item|
csv << [item.slug, item.title, item.regular_price, item.variants.count]
end
end
File.write(file,data)
puts "#{file} <-- OK!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment