ideaoforder
ideaoforder

Reputation: 1023

Variant product_id with API Ruby gem

I'm using the Shopify_api gem to grab products and variants for an app. When grabbing a variant, I can't seem to get the product_id, even though the API Doc says it should be available. Anyone know how I can get the product_id from the variant?

Upvotes: 1

Views: 268

Answers (1)

Jason N
Jason N

Reputation: 461

http://docs.shopify.com/api/product_variant does say product_id should be in the response, and if you inspect the actual response it is. The problem is that ActiveResource doesn't seem to save this as a normal attribute, if you look at https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/variant.rb, it uses this as a prefix option. The only way I figure out how to do it right now is

variant.prefix_options[:product_id]

This is also reported in ActiveResource here https://github.com/rails/rails/issues/3917

Upvotes: 1

Related Questions