Shopify 无法将产品添加到自定义集合
使用shopify gem,我试图将一个产品添加到自定义集合中Shopify 无法将产品添加到自定义集合,shopify,Shopify,使用shopify gem,我试图将一个产品添加到自定义集合中 c = ShopifyAPI::CustomCollection.first(:title => "Man") p = ShopifyAPI::Product.find(95448374) 如果我尝试: c.products << p c.save => true c.true 但该产品不会添加到自定义集合中 c = ShopifyAPI::CustomCollection.first(:title =
c = ShopifyAPI::CustomCollection.first(:title => "Man")
p = ShopifyAPI::Product.find(95448374)
如果我尝试:
c.products << p
c.save
=> true
c.true
但该产品不会添加到自定义集合中
c = ShopifyAPI::CustomCollection.first(:title => "Man")
p = ShopifyAPI::Product.find(95448374)
我也试过了
p.collections << c
p.save
=> true
p.true
但产品仍然没有添加到集合中…为什么
非常感谢您的帮助
奥古斯托你的答案就在来源中:
您必须使用add_to_集合或add_product方法,因为这些方法会创建一个Collect对象,这就是我们用来关联产品和集合的对象。您的答案在于来源:
c = ShopifyAPI::CustomCollection.first(:title => "Man")
p = ShopifyAPI::Product.find(95448374)
您必须使用add_to_集合或add_product方法,因为这些方法会创建一个Collect对象,这就是我们用来关联产品和集合的对象。Yay!非常感谢您如此快速准确的回复!耶!非常感谢您如此快速准确的回复!
c = ShopifyAPI::CustomCollection.first(:title => "Man")
p = ShopifyAPI::Product.find(95448374)