We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: InventoryItemId and ProductId Mismatch in Restocking Webhook

Solved

InventoryItemId and ProductId Mismatch in Restocking Webhook

fitneshmaniaapp
Shopify Partner
2 0 0

Hi everyone,

I’m working on a Shopify app that listens to restocking web-hooks. The web-hook triggers successfully, but the inventory-Item-Id from the web-hook payload doesn’t match the correct product-Id in my database.

Steps I’ve taken:

  • Checked web-hook response, which provides inventory-Item-Id, available, and location-Id.
  • Stored product-Id and inventory-Item-Id in my Restocking-Event model.
  • Queried inventory-Item-Id from Product-Variant using Graph-QL, but it doesn’t always return the correct product-Id.
  • Verified in Shopify’s Graph-QL Explorer, but the mismatch still exists.

Issue:

  • The inventory-Item-Id from the web-hook does not map correctly to product-Id, preventing accurate restock notifications.

Need Help With:

  1. How to correctly fetch product-Id from inventory-Item-Id?
  2. Recommended Graph-QL query or REST API endpoint for accurate mapping?
  3. Has anyone else faced this issue, and how did you solve it?

Any help would be greatly appreciated!

Thanks in advance.

Accepted Solution (1)

Joe47
Shopify Partner
62 8 21

This is an accepted solution.

Hi @fitneshmaniaapp,

 

You can fetch a product ID for an inventory item ID with a graphql query like this:

 

query GetProductIdFromInventoryItemId {
  inventoryItem(id: "gid://shopify/InventoryItem/30322695") {
    id
    variant {
      product {
        id
        title
      }
    }
  }
}

 

View solution in original post

Reply 1 (1)

Joe47
Shopify Partner
62 8 21

This is an accepted solution.

Hi @fitneshmaniaapp,

 

You can fetch a product ID for an inventory item ID with a graphql query like this:

 

query GetProductIdFromInventoryItemId {
  inventoryItem(id: "gid://shopify/InventoryItem/30322695") {
    id
    variant {
      product {
        id
        title
      }
    }
  }
}