Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2016 12:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Delete product images using the Ruby bootic API client.
require 'bootic_client'
# Configure the client with your credentials
BooticClient.configure do |c|
c.client_id = 'MY_CLIENT_ID'
c.client_secret = 'MY_CLIENT_SECRET'
c.logger = # optional
c.logging = true # optional
c.cache_store = Rails.cache # optional
# Instantiate a client
client = BooticClient.client(:client_credentials, scope: 'admin')
# Fetch the root resource and your default shop
root = client.root
shop = root.shops.first
# Iterate products and delete all images.
shop.products(status: 'all').full_set.each do |product|
# Fetch each product's detail resource
# so we can get ALL of its images
product = product.self
if product.has?(:images)
product.images.each do |a|
if a.has?(:delete_product_asset)
puts "Deleted #{product.slug}: #{a.file_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment