Product variant adding

Tourist
10 0 1

Hi, 

I am adding a product variant with the API, I get an ID returned for the variant, but when try to retrieve the variant, or even if I look in the shop, the variant is nowhere to be found.

Is there a limit to the number of variants you can create per product, and if so, why does the API return an ID for variant?

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
591 0 45

How are you trying to fetch the variant.

Variants need to be fetched in the following manner:

GET /admin/products/:product_id/variants/:variant_id.json

Variants are returned in-line with the product during an API request so if you want to verify that your variant was created correctly, just re-issue a get for the product in question.

GET /admin/products/:product_id.json

 

0 Likes
Tourist
10 0 1

After I add the variant I get the following back:

array(
        'barcode' => null,
        'compare_at_price' => null,
        'created_at' => '2013-08-27T16:57:47-04:00',
        'fulfillment_service' => 'manual',
        'grams' => (int) 0,
        'id' => (int) 351917569,
        'inventory_management' => null,
        'inventory_policy' => 'deny',
        'option1' => 'XXX',
        'option2' => null,
        'option3' => null,
        'position' => (int) 4,
        'price' => '12.00',
        'product_id' => (int) 152722079,
        'requires_shipping' => true,
        'sku' => 'XXX',
        'taxable' => true,
        'title' => 'XXX',
        'updated_at' => '2013-08-27T16:57:47-04:00',
        'inventory_quantity' => (int) 1
)

But when I refresh my shop admin for the product or re-issue a GET request for the product, The variant is not in the list of variants, It's really weird

0 Likes
Tourist
10 0 1

When I try to add 2 variants, I get the following 2 responses:

 

array(
        'barcode' => null,
        'compare_at_price' => null,
        'created_at' => '2013-08-27T17:05:35-04:00',
        'fulfillment_service' => 'manual',
        'grams' => (int) 0,
        'id' => (int) 351919839,
        'inventory_management' => null,
        'inventory_policy' => 'deny',
        'option1' => 'This is a test',
        'option2' => null,
        'option3' => null,
        'position' => (int) 4,
        'price' => '10.00',
        'product_id' => (int) 152722079,
        'requires_shipping' => true,
        'sku' => 'ABCDEF',
        'taxable' => true,
        'title' => 'This is a test',
        'updated_at' => '2013-08-27T17:05:35-04:00',
        'inventory_quantity' => (int) 1
)

 

 

array(
        'barcode' => null,
        'compare_at_price' => null,
        'created_at' => '2013-08-27T17:05:37-04:00',
        'fulfillment_service' => 'manual',
        'grams' => (int) 0,
        'id' => (int) 351919847,
        'inventory_management' => null,
        'inventory_policy' => 'deny',
        'option1' => 'XXX',
        'option2' => null,
        'option3' => null,
        'position' => (int) 5,
        'price' => '12.00',
        'product_id' => (int) 152722079,
        'requires_shipping' => true,
        'sku' => 'XXX',
        'taxable' => true,
        'title' => 'XXX',
        'updated_at' => '2013-08-27T17:05:37-04:00',
        'inventory_quantity' => (int) 1
)

 

 

Note the [position] is increasing, so it must have been added, but when I do a get on the product it's not in there, and Like I mentioned, even If I refresh on the shop, it's not there

0 Likes
Tourist
10 0 1

Found the problem.

I was adding the variants, but after I added them I called a Product Modify, with only the original variants, and not the new ones as well. So I suppose the edit call was seeing that there is only 3 variants and that the new ones was not supposed to be there. Hope that makes sense 

0 Likes