如何使用Ruby gem添加产品变体

rea*_*eal 2 ruby ruby-on-rails activeresource shopify

添加产品变体的正确方法是什么?

我成功创建了产品,它显示在我的Shopify管理员中.但价格始终为零,数量始终为无穷大.

我尝试使用inventory_quantity和price set创建变量,以及在prefix_options中设置product_id.

但是,管理员始终显示价格零和数量无限.

Rails v3.2.5
shopify_api v3.0.0
shop name: vacation-2
Run Code Online (Sandbox Code Playgroud)

我在调用API时没有出错.我只是在管理员的产品中看不到我的变体数据.

Tra*_*vis 5

确保将:inventory_management属性设置为"shopify",否则数量将不会持久.

我刚刚测试了它,它完美地工作:

product.variants << ShopifyAPI::Variant.new(
  :option1              => "Large",
  :price                => 12.95,
  :inventory_management => 'shopify',
  :inventory_quantity   => 10
)
product.save
Run Code Online (Sandbox Code Playgroud)