Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hello,
I'm simply trying to create products with variants and initial inventory levels, and I feel like I must be doing something wrong, since it's insanely complex and taking up a ton of requests.
Can someone please confirm that there is no way to set the initial inventory level for a product variant in the product create request?
Is the only way to add variant inventory levels to make a separate request to the
If this is the case, then to create a simple product with 3 variants with inventory levels, I'd have to make this series of requests:
1. Make a request to admin/products.json to create product with 3 variants
2. For every single variant, make the following requests:
Some products have 10+ variants, which would result in 20+ requests being made just to create this one product. That is really going to mess with my API rate limit since there are many users attempting to import products at the same time.
Am I doing this correctly, or am I missing something obvious?
Thank you so much,
Patrick
Solved! Go to the solution
This is an accepted solution.
Hey @Patrick_Kelly2 ,
You should be able to set inventory at a shop's primary/default location upon product creation, but if it's a multi-location shop it'll take multiple requests to set inventory quantities correctly. You might want to look into using GraphQL if you're getting into multi-location stores.
Otherwise, I just tested out this API call for a product with two variants and this is enabling inventory tracking and setting the quantity upon creation :
{ "product": { "title": "Burton Custom Freestyle 151", "body_html": "<strong>Good snowboard!</strong>", "vendor": "Burton", "product_type": "Snowboard", "variants": [ { "option1": "First", "price": "10.00", "sku": "123", "inventory_management": "shopify", "inventory_quantity": 15 }, { "option1": "Second", "price": "20.00", "sku": "123", "inventory_management": "shopify", "inventory_quantity": 5 } ] } }
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
This is an accepted solution.
Hey @Patrick_Kelly2 ,
You should be able to set inventory at a shop's primary/default location upon product creation, but if it's a multi-location shop it'll take multiple requests to set inventory quantities correctly. You might want to look into using GraphQL if you're getting into multi-location stores.
Otherwise, I just tested out this API call for a product with two variants and this is enabling inventory tracking and setting the quantity upon creation :
{ "product": { "title": "Burton Custom Freestyle 151", "body_html": "<strong>Good snowboard!</strong>", "vendor": "Burton", "product_type": "Snowboard", "variants": [ { "option1": "First", "price": "10.00", "sku": "123", "inventory_management": "shopify", "inventory_quantity": 15 }, { "option1": "Second", "price": "20.00", "sku": "123", "inventory_management": "shopify", "inventory_quantity": 5 } ] } }
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
When I try to POST this example I am getting RESPONSE 303 and redirected html.
Hey Bob,
I didn't copy this exact data, but I did add the following to my request which did work for me:
"inventory_management": "shopify", "inventory_quantity": 5
Have you been able to make a successful request otherwise?
- Patrick
Hi Josh,
Why does the Shopify API instructions not show an example of setting quantity when creating new inventory?
I see that "inventory_quantity" is depreciated for "updating" a product (update variants), but is it not depreciated for "creating" new products?
Confused as usual.
thanks,
Ron
This no longer seems to be true when creating new products?
And the store only has one inventory location.
{"error":"Write requests to inventory_quantity and inventory_quantity_adjustment are no longer supported. Please use the Inventory Levels API."}
Josh, your solution (which solves the problem in every single way), has now been explicitly disallowed by Shopify:
{ "error": "Write requests to inventory_quantity and inventory_quantity_adjustment are no longer supported. Please use the Inventory Levels API." }
Just bumping this thread again. Now that the approach recommended in this thread is deprecated, do API developers just need to deal with the trade-off between more product variants and longer product creation due to one-inventory-call-per-variant?
I realized that if product creation returns inventory_level_id in addition to inventory_item_id, then I should be able to do this in one API call via graphQL, but for now, the only approach I could find was to iterate over variants, and pull inventory_level_id's from each inventory_item_id in order to create the proper GraphQL for a bulk inventory edit.
Alternatively, perhaps the API quota could be increased for inventory updates? (right now it looks like it's 2 per second, perhaps a 10-per second burst would be allay developers concerns here, while still enforcing a 120 per-minute rate).
Thanks for your consideration, and any help you can provide.
Hi, Josh
Is your recommendation still valid?
I was able to create a product with the inventory level without a problem, when I followed your instruction. (using the endpoint for Product, not for Product Variant). However, I saw a warning notice regarding 'inventory_quantity' on the top of the Product Variant page. I am currently assuming that it is not possible to create a product variant with the inventory level, using the 'Product Variant' endpoint, at the moment, but you can create it when using the "Product" endpoint.
Am I correct on this? By the way, I am using Admin API (Restful Version) instead of GraphQL version.
Best Regards,
Howard
User | RANK |
---|---|
6 | |
4 | |
3 | |
3 | |
3 |