fix(search): resolve inStock per channel in webhooks - #2427
Merged
Conversation
Saleor resolves quantityAvailable per channel, but webhook subscriptions have no channel context - productVariant is resolved with channel_slug=None, so the loader finds no warehouses and always returns 0. Every webhook then wrote inStock: false, and since records are saved with saveObjects (full replace), even BACK_IN_STOCK overwrote the correct value. Only a full index import produced correct data, until the next webhook arrived. Fetch quantityAvailable again per channel the variant is listed in, and pass the channel-scoped value into each index's document. One query per channel covers all variants, and is skipped when inStock is not an enabled field. A failed fetch throws so Saleor retries, instead of indexing a wrong value. Also honour trackInventory: untracked variants can always be bought, but Saleor returns null for their quantityAvailable unless limitQuantityPerCheckout is set, so they were indexed as out of stock in both webhook and bulk sync. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 644d395 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lkostrowski
requested review from
peelar
and removed request for
wcislo-saleor
August 27, 2026 12:08
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2427 +/- ##
==========================================
+ Coverage 37.51% 37.54% +0.03%
==========================================
Files 1222 1223 +1
Lines 77118 77209 +91
Branches 4204 4219 +15
==========================================
+ Hits 28929 28989 +60
- Misses 47694 47725 +31
Partials 495 495
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lkostrowski
enabled auto-merge (squash)
August 27, 2026 12:41
peelar
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Saleor resolves quantityAvailable per channel, but webhook subscriptions have no channel context - productVariant is resolved with channel_slug=None, so the loader finds no warehouses and always returns 0. Every webhook then wrote inStock: false, and since records are saved with saveObjects (full replace), even BACK_IN_STOCK overwrote the correct value. Only a full index import produced correct data, until the next webhook arrived.
Fetch quantityAvailable again per channel the variant is listed in, and pass the channel-scoped value into each index's document. One query per channel covers all variants, and is skipped when inStock is not an enabled field. A failed fetch throws so Saleor retries, instead of indexing a wrong value.
Also honour trackInventory: untracked variants can always be bought, but Saleor returns null for their quantityAvailable unless limitQuantityPerCheckout is set, so they were indexed as out of stock in both webhook and bulk sync.
Scope of the PR
Related issues
Checklist