Extend pricing data in Algolia (#998)
Co-authored-by: Krzysztof Wolski <krzysztof.k.wolski@gmail.com>
This commit is contained in:
parent
767d0be722
commit
1982d81f17
4 changed files with 78 additions and 2 deletions
33
.changeset/selfish-kids-heal.md
Normal file
33
.changeset/selfish-kids-heal.md
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
"saleor-app-search": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added a new `pricing` field to the Algolia object representation. It now passes variant pricing representation from GraphQL:
|
||||||
|
|
||||||
|
```graphQL
|
||||||
|
price {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
discount {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onSale
|
||||||
|
priceUndiscounted {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
|
@ -10,7 +10,26 @@ fragment ProductVariantData on ProductVariant {
|
||||||
price {
|
price {
|
||||||
gross {
|
gross {
|
||||||
amount
|
amount
|
||||||
currency
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
discount {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onSale
|
||||||
|
priceUndiscounted {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
net {
|
||||||
|
amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,9 +78,15 @@ export class AlgoliaSearchProvider implements SearchProvider {
|
||||||
"productId",
|
"productId",
|
||||||
"inStock",
|
"inStock",
|
||||||
"categories",
|
"categories",
|
||||||
"grossPrice",
|
|
||||||
"attributes",
|
"attributes",
|
||||||
"collections",
|
"collections",
|
||||||
|
"pricing.price.net",
|
||||||
|
"pricing.price.gross",
|
||||||
|
"pricing.discount.net",
|
||||||
|
"pricing.discount.gross",
|
||||||
|
"pricing.priceUndiscounted.net",
|
||||||
|
"pricing.priceUndiscounted.gross",
|
||||||
|
"pricing.onSale",
|
||||||
],
|
],
|
||||||
attributeForDistinct: "productId",
|
attributeForDistinct: "productId",
|
||||||
numericAttributesForFiltering: ["grossPrice"],
|
numericAttributesForFiltering: ["grossPrice"],
|
||||||
|
|
|
@ -134,7 +134,25 @@ export function productAndVariantToAlgolia({
|
||||||
descriptionPlaintext: EditorJsPlaintextRenderer({ stringData: product.description }),
|
descriptionPlaintext: EditorJsPlaintextRenderer({ stringData: product.description }),
|
||||||
slug: product.slug,
|
slug: product.slug,
|
||||||
thumbnail: product.thumbnail?.url,
|
thumbnail: product.thumbnail?.url,
|
||||||
|
/**
|
||||||
|
* Deprecated
|
||||||
|
*/
|
||||||
grossPrice: listing?.price?.amount,
|
grossPrice: listing?.price?.amount,
|
||||||
|
pricing: {
|
||||||
|
price: {
|
||||||
|
net: variant.pricing?.price?.net.amount,
|
||||||
|
gross: variant.pricing?.price?.gross.amount,
|
||||||
|
},
|
||||||
|
onSale: variant.pricing?.onSale,
|
||||||
|
discount: {
|
||||||
|
net: variant.pricing?.discount?.net.amount,
|
||||||
|
gross: variant.pricing?.discount?.gross.amount,
|
||||||
|
},
|
||||||
|
priceUndiscounted: {
|
||||||
|
net: variant.pricing?.priceUndiscounted?.net.amount,
|
||||||
|
gross: variant.pricing?.priceUndiscounted?.gross.amount,
|
||||||
|
},
|
||||||
|
},
|
||||||
inStock,
|
inStock,
|
||||||
categories: categoryHierarchicalFacets(variant),
|
categories: categoryHierarchicalFacets(variant),
|
||||||
collections: product.collections?.map((collection) => collection.name) || [],
|
collections: product.collections?.map((collection) => collection.name) || [],
|
||||||
|
|
Loading…
Reference in a new issue