Skip to content

Commit

Permalink
extending pricing model in algolia
Browse files Browse the repository at this point in the history
  • Loading branch information
lkostrowski committed Sep 7, 2023
1 parent 4a2275e commit 3718f17
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-kids-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-app-search": minor
---

Added new "pricing" field to Algolia object representation. It now contains "onSale", "discount gross amount", "undiscounted gross amount", "gross amount" and "channel listing amount". The "grossPrice" field is deprecated now, its value is the same as "channel listing amount".
14 changes: 12 additions & 2 deletions apps/search/graphql/fragments/ProductVariantData.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ fragment ProductVariantData on ProductVariant {
price {
gross {
amount
currency
}
}
discount {
gross {
amount
}
}
onSale
priceUndiscounted {
gross {
amount
}
}
}
Expand All @@ -19,7 +29,7 @@ fragment ProductVariantData on ProductVariant {
id
channel {
slug
currencyCode
currencyCode
}
price {
currency
Expand Down
6 changes: 5 additions & 1 deletion apps/search/src/lib/algolia/algoliaSearchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ export class AlgoliaSearchProvider implements SearchProvider {
"productId",
"inStock",
"categories",
"grossPrice",
"attributes",
"collections",
"pricing.grossAmount",
"pricing.onSale",
"pricing.discountGrossAmount",
"pricing.undiscountedGrossAmount",
"pricing.channelListingPriceAmount",
],
attributeForDistinct: "productId",
numericAttributesForFiltering: ["grossPrice"],
Expand Down
10 changes: 10 additions & 0 deletions apps/search/src/lib/algolia/algoliaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,17 @@ export function productAndVariantToAlgolia({
descriptionPlaintext: EditorJsPlaintextRenderer({ stringData: product.description }),
slug: product.slug,
thumbnail: product.thumbnail?.url,
/**
* Deprecated
*/
grossPrice: listing?.price?.amount,
pricing: {
grossAmount: variant.pricing?.price?.gross.amount,
onSale: variant.pricing?.onSale,
discountGrossAmount: variant.pricing?.discount?.gross.amount,
undiscountedGrossAmount: variant.pricing?.priceUndiscounted?.gross.amount,
channelListingPriceAmount: listing?.price?.amount,
},
inStock,
categories: categoryHierarchicalFacets(variant),
collections: product.collections?.map((collection) => collection.name) || [],
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"*.{ts,tsx,md,js,jsx}": "cspell --no-must-find-files"
},
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"@saleor/app-sdk": "0.43.1"
}
},
"private": true,
"workspaces": [
"apps/*",
"packages/*",
"templates/*"
],
"pnpm": {
"overrides": {
"@saleor/app-sdk": "0.43.1"
}
}
]
}

0 comments on commit 3718f17

Please sign in to comment.