Created
June 29, 2021 08:10
-
-
Save juque/7ff26e21172196695ec1897ceadd83eb to your computer and use it in GitHub Desktop.
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
| shop = root.shops.first | |
| products = shop.products(collections: "deals", class: "product").full_set | |
| file = 'backup_variants_deals.csv' | |
| columns = ["sku", "regular_price", "sale_price"] | |
| data = CSV.generate do |csv| | |
| csv << columns | |
| products.each do |product| | |
| variants = product.variants | |
| variants.each do |variant| | |
| csv << [variant.sku, variant.regular_price, variant.sale_price] | |
| end | |
| 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