Create a Product with inventory

Peekup
New Member
1 0 0

I want to create a product with a inventory tacking and a quantity. in the SDK samples I can't find it.

I don't want to create variants or naythign special.

In the UI when I configure it manually it looks like this:

Peekup_0-1618938758409.png

 

 

when i look at the documentation i can only find the quantity inside the variants. https://shopify.dev/docs/admin-api/rest/reference/products/product#create-2021-04

 

what is the indended way to achieve this?

0 Likes
_JB
Shopify Staff
Shopify Staff
817 96 176

Hey @Peekup,

All products have variants, even if you don't explicitly create one. When a product is created without multiple variants options, Shopify will create a default variant. This is because certain data like price, SKU, barcode etc. are stored on the variant object in the database.

Inventory goes one step further, as inventory quantities are store on the inventory_item object, which belongs to the variant. The inventory item is created automatically as well, so when you create a product the response will include information about the default variant including the inventory_item_id.

Assigning inventory is to be done in an additional call after a product is created. Grab the inventory_item_id from the product#create response, and use that id to send another call to inventory_level endpoint. This tutorial provides a detailed breakdown of the inventory management process.

JB | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

0 Likes