ruby on rails - Shopify API Variant not being returned with product_id attribute -


so i'm using shopify gem access shopify api , noticed product_id attribute not being returned within response body simple shopifyapi::variant.find call.

1.9.3p194> shopifyapi::variant.find(209901733)  => #<shopifyapi::variant:0x007fbf7225d3f0 @attributes={"barcode"=>nil, "compare_at_price"=>"198.00", "created_at"=>"2012-03-23t14:11:39+11:00", "fulfillment_service"=>"manual", "grams"=>1000, "id"=>209901733, "inventory_management"=>"shopify", "inventory_policy"=>"deny", "option1"=>"38", "option2"=>"ivory mini twill", "option3"=>nil, "position"=>16, "price"=>"198.00", "requires_shipping"=>true, "sku"=>"3063", "taxable"=>true, "title"=>"38 / ivory mini twill", "updated_at"=>"2013-04-24t10:25:27+10:00", "inventory_quantity"=>2}, @prefix_options={}, @persisted=true>  

according new documentation has been published here, product_id field should returned.

get /admin/variants/#{id}.json hide response http/1.1 200 ok  {   "variant": {     "barcode": "1234_pink",     "compare_at_price": null,     "created_at": "2013-05-01t15:35:21-04:00",     "fulfillment_service": "manual",     "grams": 200,     "id": 808950810,     "inventory_management": "shopify",     "inventory_policy": "continue",     "option1": "pink",     "option2": null,     "option3": null,     "position": 1,     "price": "199.00",     "product_id": 632910392,     "requires_shipping": true,     "sku": "ipod2008pink",     "taxable": true,     "title": "pink",     "updated_at": "2013-05-01t15:35:21-04:00",     "inventory_quantity": 10   } } 

it in json, not in activeresource created json. reason code in variant activeresource:

    self.prefix = "/admin/products/:product_id/"      def self.prefix(options={})       options[:product_id].nil? ? "/admin/" : "/admin/products/#{options[:product_id]}/"     end 

if want can make own class fetching singleton variants:

      module shopifyapi         class variantwithproduct < base           self.prefix = "/admin/"           self.element_name = "variant"           self.collection_name = "variants"         end       end 

and use class fetch single variants id:

    shopifyapi::variantwithproduct.find(xxxxxx) 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -