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, 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.
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |