Class: ShopifyAPI::Product
- Inherits:
-
Base
show all
- Includes:
- Events, Metafields
- Defined in:
- lib/shopify_api/resources/product.rb
Instance Method Summary
(collapse)
Methods included from Metafields
#add_metafield, #metafields
Methods included from Events
#events
Methods included from Countable
#count
#encode
Instance Method Details
- (Object) add_to_collection(collection)
25
26
27
|
# File 'lib/shopify_api/resources/product.rb', line 25
def add_to_collection(collection)
collection.add_product(self)
end
|
- (Object) collections
17
18
19
|
# File 'lib/shopify_api/resources/product.rb', line 17
def collections
CustomCollection.find(:all, :params => {:product_id => self.id})
end
|
- (Object) price_range
7
8
9
10
11
12
13
14
15
|
# File 'lib/shopify_api/resources/product.rb', line 7
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
|
- (Object) remove_from_collection(collection)
29
30
31
|
# File 'lib/shopify_api/resources/product.rb', line 29
def remove_from_collection(collection)
collection.remove_product(self)
end
|
- (Object) smart_collections
21
22
23
|
# File 'lib/shopify_api/resources/product.rb', line 21
def smart_collections
SmartCollection.find(:all, :params => {:product_id => self.id})
end
|