Skip to content

Commit

Permalink
Feature: isvariantof on VTEX legacy suggestions (#396)
Browse files Browse the repository at this point in the history
* feat: return isVariantOf on legacy suggestions loader

* feat: return isvariantof on vtex legacy suggestions

---------

Co-authored-by: guitavano <tavano62@gmail.com>
  • Loading branch information
bruno-monteiro1 and guitavano authored Feb 16, 2024
1 parent 444489c commit b56175d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vtex/loaders/legacy/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,25 @@ const loaders = async (
const products: Suggestion["products"] = suggestions.itemsReturned
.filter(({ items }) => !!items.length)
.map(
({ items: [{ productId, itemId, imageUrl, name }], href }): Product => {
({
items: [{ productId, itemId, imageUrl, name, nameComplete }],
href,
}): Product => {
const url = new URL(href);

return {
"@type": "Product",
productID: itemId,
sku: itemId,
inProductGroupWithID: productId,
isVariantOf: {
"@type": "ProductGroup",
name: nameComplete,
url: new URL(href).pathname,
hasVariant: [],
additionalProperty: [],
productGroupID: productId,
},
image: [{ "@type": "ImageObject", url: imageUrl }],
name,
url: url.pathname + url.search + url.hash,
Expand Down

0 comments on commit b56175d

Please sign in to comment.