Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shopify 无法将产品添加到自定义集合_Shopify - Fatal编程技术网

Shopify 无法将产品添加到自定义集合

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 =

使用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 => "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)