Creating a Product Via the REST API and specifying the inventory location to use

Highlighted
Tourist
9 0 2

Hello 

 

Using the ShopifyAPI (in ruby) how can we specify the inventory location to use when creating a product or variant?

When creating the product or variant I'd like the inventory_item inventory_level only to be present for a single specified location_id

 

0 Likes
Highlighted

Hello 
For create new product and specifying inventory location You can used below Code

Adjust the available quantity of an inventory item by 5 at a single location

POST /admin/api/#{api_version}/inventory_levels/adjust.json
{
"location_id": 905684977,
"inventory_item_id": 808950810,
"available_adjustment": 5
}

For more details please reffer below link
https://help.shopify.com/en/api/reference/inventory/inventorylevel#adjust-2019-07

Want to modify or incorporate custom changes on store, Hire us
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Whats app
Free Website Review and advice for sale from Shopify Conversion Experts | Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Shopify SEO ; Digital Marketing & amp | Site Speed Optimization | Performance Site Audit
0 Likes
Highlighted
Tourist
9 0 2

Thank you, what I'm hoping to do is create the correct inventory_level when the product is created. Right now it seems that the ShopifyAPI::Product.new call creates a inventory_level record in a default location, which then has to be deleted later. What I would like is to specify the inventory_level in the create call

0 Likes
Highlighted

Hello 

 

a) First Use Location API to get Your store Location details and then Get location id from that array

GET /admin/api/#{api_version}/locations.json


b) After getting location ID pass to below API

 

POST /admin/api/#{api_version}/inventory_levels/adjust.json
{
"location_id": "here pass location ID",
"inventory_item_id": 808950810,
"available_adjustment": 5
}

 


Below Link for How to Use Location API
https://help.shopify.com/en/api/reference/inventory/location

Want to modify or incorporate custom changes on store, Hire us
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Whats app
Free Website Review and advice for sale from Shopify Conversion Experts | Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Shopify SEO ; Digital Marketing & amp | Site Speed Optimization | Performance Site Audit
0 Likes
Highlighted
Tourist
9 0 2

Hi this is true after the product has been created.

 

however, I'm trying to specify the location for the stock at the time the product is created, so that I don't have to delete the inventory item after that when I add the location that I want

2 Likes
Highlighted
Tourist
5 0 3

Wow. What could be better than making one API call? I know ... two API calls.

 

This is a terrible change. Stores that sell unique items now have double the number of API calls to make, because creating a product isn't good enough anymore.

1 Like
Highlighted
Tourist
12 0 0

I am trying to do the same thing - also in ruby

For now it looks like going to have to create the product and variants, then do a separate API call to connect the inventory items to the locations

 

Have you found any other way to do this?

0 Likes
Highlighted

I am in the same boat and this seems to be a flaw in the API design.  Especially when I am creating over a 1000 new products that I want to make sure are in the correct location to start and not have to then remove the default location from newly created product.

 

I think the simple ask is if the POST for product creation could also take a param for locationId (optional)

2 Likes