Class: ShopifyAPI::CustomCollection
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- ShopifyAPI::CustomCollection
show all
- Includes:
- Events, Metafields
- Defined in:
- lib/shopify_api/resources/custom_collection.rb
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_product(product) ⇒ Object
10
11
12
|
# File 'lib/shopify_api/resources/custom_collection.rb', line 10
def add_product(product)
Collect.create(collection_id: self.id, product_id: product.id)
end
|
#products ⇒ Object
6
7
8
|
# File 'lib/shopify_api/resources/custom_collection.rb', line 6
def products
Product.find(:all, params: { collection_id: self.id })
end
|
#remove_product(product) ⇒ Object
14
15
16
17
|
# File 'lib/shopify_api/resources/custom_collection.rb', line 14
def remove_product(product)
collect = Collect.find(:first, params: { collection_id: self.id, product_id: product.id })
collect.destroy if collect
end
|