custom_collection.rb 484 B

12345678910111213141516171819
  1. module ShopifyAPI
  2. class CustomCollection < Base
  3. include Events
  4. include Metafields
  5. def products
  6. Product.find(:all, :params => {:collection_id => self.id})
  7. end
  8. def add_product(product)
  9. Collect.create(:collection_id => self.id, :product_id => product.id)
  10. end
  11. def remove_product(product)
  12. collect = Collect.find(:first, :params => {:collection_id => self.id, :product_id => product.id})
  13. collect.destroy if collect
  14. end
  15. end
  16. end