Unable to update inventory location or QTY via API

Solved
Highlighted
New Member
5 0 0

Hello! I try to update inventory QTY and get an error.

I'm using library https://github.com/phpclassic/php-shopify and do as here:

 

1. Adjusts the inventory level of an inventory item at a single location

My code:

$shopify = PHPShopify\ShopifySDK::config($config);
$data = [
	'location_id' => 17109517,
	'inventory_item_id' => 13915495465005,
	'available_adjustment' => 5,
];
$result = $shopify->InventoryLevel->adjust($data);

I get a result:

Not Found

 

The documentation says for such response:

Adjusting inventory levels at a non-existent location fails and returns an error.

 

a) Script generate URL:

https://***@***.myshopify.com/admin/api/2019-10/inventory_levels/adjust.json - it's OK

 

b) I have the created location. I can see it by URL:

https://***.myshopify.com/admin/settings/locations/17109517 - it's OK

 

c) I have a product https://***.myshopify.com/admin/products/1516929744941 that have a variant https://***.myshopify.com/admin/products/1516929744941/variants/13915495465005 - it's OK

 

All the data is correct and I don't understand why I get an error and what else I need to do.

 

2. Also I tried to do Connects an inventory item to a location:

 

$data = [
	'location_id' => 17109517,
	'inventory_item_id' => 13915495465005,
];
$result = $shopify->InventoryLevel->connect($data);

But I get an error:

 

Not Found

 

The documentation says for such response:

Connecting an inventory item to a non-existent location fails and returns an error.

 

3. Also I tried to Set the inventory level for an inventory item at a location

$data = [
	'location_id' => 17109517,
	'inventory_item_id' => 13915495465005,
	'available' => 5,
];
$result = $shopify->InventoryLevel->set($data);

No such error in the documentation.

---------------------

The first two errors indicate an bad location. But I have this location and I show you it in screenshots:

screen1.jpg

 

screen2.jpg

 

screen3.jpg

 

Help me, people, please.

0 Likes
New Member
5 0 0

I add:

$shopify->InventoryLevel->set($data);

returns also Not Found

0 Likes

Success.

Shopify Staff
Shopify Staff
67 7 9

Hey @Victor_K_,

 

It looks like you're using the variant_id in your code instead of the inventory_item_id. Variants have a 1:1 relationship with inventory_items, but note that they have different ids.

 

For the variant products/1516929744941/variants/13915495465005, the inventory_item_id is 14171064598573. You can see this by doing a GET to the product or variant (screenshot here)

 

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
New Member
5 0 0

Thank you, good person. It works :-)

0 Likes