ruby-on-railsrubyshopifyvariants

Updating quantities in shopify using ruby


I'm trying to update attributes in shopify with the ruby API. What I have right now is

product.variants = ShopifyAPI::Variant.new(:id => 753289571, :price => 12.00, :inventory_management => 'shopify', :inventory_quantity   => '100' ) 

Which I was expecting for the variant with id 753.... to update the price to 12.00 and the current quantity to 100. When I do product.save it returns true. However, nothing has changed.

What am I doing wrong here?


Solution

  • Why not update the variant directly?

    variant = ShopifyAPI::Variant.find(753289571)
    variant.price = 12
    variant.save