Class: ShopifyAPI::Product

Inherits:
Base
  • Object
show all
Defined in:
lib/shopify_api.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Countable

#count

Class Method Details

.shareObject

Share all items of this store with the shopify marketplace



271
# File 'lib/shopify_api.rb', line 271

def self.share; post :share;  end

.unshareObject



272
# File 'lib/shopify_api.rb', line 272

def self.unshare; delete :share; end

Instance Method Details

#add_to_collection(collection) ⇒ Object



293
294
295
# File 'lib/shopify_api.rb', line 293

def add_to_collection(collection)
  collection.add_product(self)
end

#collectionsObject



285
286
287
# File 'lib/shopify_api.rb', line 285

def collections
  CustomCollection.find(:all, :params => {:product_id => self.id})
end

#price_rangeObject

compute the price range



275
276
277
278
279
280
281
282
283
# File 'lib/shopify_api.rb', line 275

def price_range
  prices = variants.collect(&:price)
  format =  "%0.2f"
  if prices.min != prices.max
    "#{format % prices.min} - #{format % prices.max}"
  else
    format % prices.min
  end
end

#remove_from_collection(collection) ⇒ Object



297
298
299
# File 'lib/shopify_api.rb', line 297

def remove_from_collection(collection)
  collection.remove_product(self)
end

#smart_collectionsObject



289
290
291
# File 'lib/shopify_api.rb', line 289

def smart_collections
  SmartCollection.find(:all, :params => {:product_id => self.id})
end