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



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

def self.share; post :share;  end

.unshareObject



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

def self.unshare; delete :share; end

Instance Method Details

#add_to_collection(collection) ⇒ Object



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

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

#collectionsObject



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

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

#price_rangeObject

compute the price range



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

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



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

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

#smart_collectionsObject



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

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