-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: get first available item (sku) instead of first item (sku) #2141
Conversation
…products and suggestions query
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2964077:
|
const maybeSku = product.items.find((item) => | ||
item.sellers.some((item) => inStock(item.commertialOffer)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized one thing: if a product has no available SKUs but matches the search query, previously, it would return as an Out Of Stock item.
The proposed logic would make it not appear at the search page in those cases.
I think for us to match the same behavior and fix the issue, we should make something like the suggestion below. I think we have to change this in v1 as well.
const maybeSku = product.items.find((item) => | |
item.sellers.some((item) => inStock(item.commertialOffer)) | |
) | |
const maybeSku = product.items.find((item) => | |
item.sellers.some((item) => inStock(item.commertialOffer)) | |
) ?? product.items[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. we kind of do that in the product query, but it is missing for products
and suggestions
.
Done here
after some discussion with the team, we understand that
|
What's the purpose of this pull request?
This PR aims to get first available item (sku) instead of first item (sku) in
products
andsuggestions
queries.Reference in v1: #1834
Address this issue
How it works?
While in search Page and PLP, FastStore API products/suggestions search query was getting always the first
item
(sku) from theproduct.items
. In this case, we should get the first available item.How to test it?
Check the preview link from starters store, with the tests mentioned in the issue.
Starters Deploy Preview
PR
Preview
References
https://storeframework.myvtex.com/api/io/_v/api/intelligent-search/product_search/trade-policy/1/?hideUnavailableItems=true&q=Apple%20Magic%20Mouse