Class: DuodealerAPI::Product
Instance Method Summary
collapse
Methods included from Metafields
#add_metafield, #metafields
Methods included from Events
#events
Methods inherited from Base
activate_session, api_version, api_version=, #as_json, clear_session, early_july_pagination?, #encode, headers, init_prefix, init_prefix_explicit, #persisted?, prefix, prefix=, prefix_source, resource_prefix, resource_prefix=, version_validation!
Methods included from Countable
#count
Instance Method Details
#add_to_collection(collection) ⇒ Object
27
28
29
|
# File 'lib/duodealer_api/resources/product.rb', line 27
def add_to_collection(collection)
collection.add_product(self)
end
|
#collections ⇒ Object
19
20
21
|
# File 'lib/duodealer_api/resources/product.rb', line 19
def collections
CustomCollection.find(:all, :params => {:product_id => self.id})
end
|
#price_range ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/duodealer_api/resources/product.rb', line 9
def price_range
prices = variants.collect(&:price).collect(&:to_f)
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
31
32
33
|
# File 'lib/duodealer_api/resources/product.rb', line 31
def remove_from_collection(collection)
collection.remove_product(self)
end
|
#smart_collections ⇒ Object
23
24
25
|
# File 'lib/duodealer_api/resources/product.rb', line 23
def smart_collections
SmartCollection.find(:all, :params => {:product_id => self.id})
end
|