-
Notifications
You must be signed in to change notification settings - Fork 68
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
feat: product list return kitlook array #98
Conversation
const [product] = await vcsDeprecated | ||
[ | ||
`GET /api/catalog_system/pub/products/search/:term?` | ||
]( | ||
{ | ||
...params, | ||
fq: [`skuId:${item.items[0].itemId}`], | ||
}, | ||
{ | ||
deco: { cache: "stale-while-revalidate" }, | ||
headers: withSegmentCookie(segment), | ||
}, | ||
).then((res: Response) => res.json()) as VTEXProduct[]; | ||
|
||
const kitItems: VTEXProduct[] = | ||
product.items[0].isKit && product.items[0].kitItems | ||
? await vcsDeprecated | ||
["GET /api/catalog_system/pub/products/search/:term?"]({ | ||
...params, | ||
fq: product.items[0].kitItems.map((item) => | ||
`skuId:${item.itemId}` | ||
), | ||
}, { deco: { cache: "stale-while-revalidate" } }).then(( | ||
res: Response, | ||
) => res.json()) | ||
: []; |
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.
You're doing multiple requests here when you could batch it
Please, follow the withIsSimilarTo
function down below that you'll find something already implemented for this.
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 refactored the code.
Now we have a single source of truth to return products with kitlook, facilitating implementation in other layers after this has been agreed.
The API: /api/io/_v/api/intelligent-search/product_search/*facets it does not return kit information, which is why when you activate the kit option we look for the products it contains in the legacy API
The legacy API itself returns if the product is a kit and if it is the ids of the items that make up the kitlook
Therefore, I make a request to have these products and format in schema.org standards
The return we have is:
[!EDIT]
If the product does not have a kit or the Active Kit Items option is not activated, the return remains unchanged.
With this data in the product, we can manipulate kit products on shelves on any page, as well as send each kit item to checkout
Thanks.
Hi guys! @jonathanwlopes went on a trip so I'm resuming his PR at #120; this one should be closed |
related to #119 |
Here we need an array with all kitlook products
The isKit property was added to the loader because this mapping needs to go through each item in the list, and in stores that do not use kitlook it will not be necessary to activate
When mapped and a kitlook product is found, the main product will have an array of kitItems
This array has the kit products, with the standard product information
Reason: In some cases the retailer needs to remove items from stock individually from the kit created on the platform, with this array we can handle item by item in the frontend, previously when used this loader only had the entire kit product without its individual items