@graphcommerce/algolia-products 9.1.0-canary.34 → 9.1.0-canary.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/mesh/algoliaHitToMagentoProduct.ts +13 -8
- package/mesh/getCurrency.ts +7 -0
- package/mesh/getSortedIndex.ts +1 -1
- package/mesh/resolvers.ts +9 -2
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @graphcommerce/algolia-products
|
|
2
2
|
|
|
3
|
+
## 9.1.0-canary.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`90e8850`](https://github.com/graphcommerce-org/graphcommerce/commit/90e885059b0203a8802e5ab753ac061b079ebcd6) - Support multiple currency displays from algolia ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
## 9.1.0-canary.35
|
|
10
|
+
|
|
3
11
|
## 9.1.0-canary.34
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -33,17 +33,21 @@ function mapPriceRange(
|
|
|
33
33
|
price: AlgoliaProductHitAdditionalProperties['price'],
|
|
34
34
|
storeConfig: GetStoreConfigReturn,
|
|
35
35
|
customerGroup = 0,
|
|
36
|
+
currencyHeader?: string,
|
|
36
37
|
): PriceRange {
|
|
37
38
|
if (!storeConfig?.default_display_currency_code) throw new Error('Currency is required')
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
-
const currency = storeConfig.default_display_currency_code as CurrencyEnum
|
|
40
|
+
const curr = currencyHeader ?? storeConfig.default_display_currency_code
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const key = curr as keyof AlgoliaPrice
|
|
43
|
+
const itemPrice = price?.[key] ?? price?.[storeConfig.default_display_currency_code]
|
|
44
|
+
const currency = (price?.[key] ? key : storeConfig.default_display_currency_code) as CurrencyEnum
|
|
44
45
|
|
|
45
|
-
const
|
|
46
|
-
const
|
|
46
|
+
const maxRegular = itemPrice?.default_max ?? 0
|
|
47
|
+
const maxFinal = itemPrice?.[`group_${customerGroup}_max`] ?? itemPrice?.default_max ?? 0
|
|
48
|
+
|
|
49
|
+
const minRegular = itemPrice?.default_max ?? 0
|
|
50
|
+
const minFinal = itemPrice?.[`group_${customerGroup}`] ?? itemPrice?.default
|
|
47
51
|
|
|
48
52
|
return {
|
|
49
53
|
maximum_price: {
|
|
@@ -65,7 +69,7 @@ function mapPriceRange(
|
|
|
65
69
|
minimum_price: {
|
|
66
70
|
regular_price: {
|
|
67
71
|
currency,
|
|
68
|
-
value:
|
|
72
|
+
value: minRegular,
|
|
69
73
|
},
|
|
70
74
|
final_price: {
|
|
71
75
|
currency,
|
|
@@ -145,6 +149,7 @@ export function algoliaHitToMagentoProduct(
|
|
|
145
149
|
hit: Algoliahit,
|
|
146
150
|
storeConfig: GetStoreConfigReturn,
|
|
147
151
|
customerGroup: number,
|
|
152
|
+
currency: string | undefined,
|
|
148
153
|
): (ProductsItemsItem & { staged: boolean }) | null {
|
|
149
154
|
const { objectID, additionalProperties } = hit
|
|
150
155
|
if (!assertAdditional(additionalProperties)) return null
|
|
@@ -180,7 +185,7 @@ export function algoliaHitToMagentoProduct(
|
|
|
180
185
|
uid: btoa(objectID),
|
|
181
186
|
id: Number(objectID),
|
|
182
187
|
sku: Array.isArray(sku) ? sku[0] : `${sku}`,
|
|
183
|
-
price_range: mapPriceRange(price, storeConfig, customerGroup),
|
|
188
|
+
price_range: mapPriceRange(price, storeConfig, customerGroup, currency),
|
|
184
189
|
created_at: created_at ? new Date(created_at).toISOString() : null,
|
|
185
190
|
stock_status: is_stock ? 'IN_STOCK' : 'OUT_OF_STOCK',
|
|
186
191
|
review_count: 0,
|
package/mesh/getSortedIndex.ts
CHANGED
|
@@ -25,7 +25,7 @@ export async function getSortedIndex(
|
|
|
25
25
|
|
|
26
26
|
if (candidates.length === 0) {
|
|
27
27
|
console.warn(
|
|
28
|
-
`[@graphcommerce/algolia-products] WARNING: Expecting virtual replica but couldn't find the expected index for attr ${attr} with ${dir}, please add to the Algolia settings in the Magento Admin Panel. Falling back to baseIndex.`,
|
|
28
|
+
`[@graphcommerce/algolia-products] WARNING: Expecting virtual replica but couldn't find the expected index for attr ${attr} with ${dir}, please add to the Algolia settings in the Magento Admin Panel. Falling back to baseIndex: ${baseIndex}.`,
|
|
29
29
|
)
|
|
30
30
|
return baseIndex
|
|
31
31
|
}
|
package/mesh/resolvers.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AlgoliasearchResponse, Resolvers } from '@graphcommerce/graphql-mesh'
|
|
1
|
+
import type { AlgoliasearchResponse, MeshContext, Resolvers } from '@graphcommerce/graphql-mesh'
|
|
2
2
|
import { hasSelectionSetPath } from '@graphcommerce/graphql-mesh'
|
|
3
3
|
import type { GraphQLError, GraphQLResolveInfo } from 'graphql'
|
|
4
4
|
import { algoliaFacetsToAggregations, getCategoryList } from './algoliaFacetsToAggregations'
|
|
@@ -6,6 +6,7 @@ import type { ProductsItemsItem } from './algoliaHitToMagentoProduct'
|
|
|
6
6
|
import { algoliaHitToMagentoProduct } from './algoliaHitToMagentoProduct'
|
|
7
7
|
import { getAlgoliaSettings } from './getAlgoliaSettings'
|
|
8
8
|
import { getAttributeList } from './getAttributeList'
|
|
9
|
+
import { getCurrencyHeader } from './getCurrency'
|
|
9
10
|
import { getFilterTypes } from './getFilterTypes'
|
|
10
11
|
import { getGroupId } from './getGroupId'
|
|
11
12
|
import { getIndexName } from './getIndexName'
|
|
@@ -92,9 +93,15 @@ export const resolvers: Resolvers = {
|
|
|
92
93
|
const items: (ProductsItemsItem | null)[] = []
|
|
93
94
|
|
|
94
95
|
const config = await getStoreConfig(context)
|
|
96
|
+
|
|
95
97
|
for (const hit of root.algoliaSearchResults.hits) {
|
|
96
98
|
if (hit?.objectID) {
|
|
97
|
-
const product = algoliaHitToMagentoProduct(
|
|
99
|
+
const product = algoliaHitToMagentoProduct(
|
|
100
|
+
hit,
|
|
101
|
+
config,
|
|
102
|
+
getGroupId(context),
|
|
103
|
+
getCurrencyHeader(context),
|
|
104
|
+
)
|
|
98
105
|
items.push(product)
|
|
99
106
|
}
|
|
100
107
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/algolia-products",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.1.0-canary.
|
|
5
|
+
"version": "9.1.0-canary.36",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"generate": "tsx scripts/generate-spec.mts"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@graphcommerce/google-datalayer": "^9.1.0-canary.
|
|
19
|
-
"@graphcommerce/graphql": "^9.1.0-canary.
|
|
20
|
-
"@graphcommerce/graphql-mesh": "^9.1.0-canary.
|
|
21
|
-
"@graphcommerce/magento-customer": "^9.1.0-canary.
|
|
22
|
-
"@graphcommerce/magento-product": "^9.1.0-canary.
|
|
23
|
-
"@graphcommerce/magento-search": "^9.1.0-canary.
|
|
24
|
-
"@graphcommerce/next-config": "^9.1.0-canary.
|
|
25
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
|
18
|
+
"@graphcommerce/google-datalayer": "^9.1.0-canary.36",
|
|
19
|
+
"@graphcommerce/graphql": "^9.1.0-canary.36",
|
|
20
|
+
"@graphcommerce/graphql-mesh": "^9.1.0-canary.36",
|
|
21
|
+
"@graphcommerce/magento-customer": "^9.1.0-canary.36",
|
|
22
|
+
"@graphcommerce/magento-product": "^9.1.0-canary.36",
|
|
23
|
+
"@graphcommerce/magento-search": "^9.1.0-canary.36",
|
|
24
|
+
"@graphcommerce/next-config": "^9.1.0-canary.36",
|
|
25
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.36",
|
|
26
26
|
"react": "^18.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|