Reputation: 1150
Using the shopify gem I'm trying to add a product to a custom collection.
c = ShopifyAPI::CustomCollection.first(:title => "Man")
p = ShopifyAPI::Product.find(95448374)
If I try:
c.products << p
c.save
=> true
But the product is not added to the custom collection.
I also tried
p.collections << c
p.save
=> true
But still the product is not added to the collection...why?
Any help is greatly appreciated!
Augusto
Upvotes: 1
Views: 189
Reputation: 38598
Your answer lies in the source:
https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/product.rb#L30
You have to use the add_to_collection or add_product methods because these create a Collect object, which is what we use to associate a product and collection.
Upvotes: 1