From c6f96e37dfb1c1d7671fc30afa78d30c494810b1 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 28 May 2024 11:28:47 -0600 Subject: [PATCH 1/2] fix(store-mobx/searchresultstore): adding variant option for backgroundImageUrl --- .../src/Search/Stores/SearchResultStore.ts | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts b/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts index b8c301d8d..b246c1b4c 100644 --- a/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts +++ b/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts @@ -119,16 +119,19 @@ export class Banner { export type VariantData = { mappings: SearchResponseModelResultMappings; attributes: Record; - options: Record< - string, - { - value: string; - attributeId?: string; - optionId?: string; - } - >; + options: VariantDataOptions; }; +export type VariantDataOptions = Record< + string, + { + value: string; + backgroundImageUrl?: string; + attributeId?: string; + optionId?: string; + } +>; + type ProductMinimal = { id: string; attributes: Record; @@ -505,6 +508,8 @@ export class VariantSelection { if (this.config.thumbnailBackgroundImages) { mappedValue.backgroundImageUrl = thumbnailImageUrl; + } else if (variant.options[this.field].backgroundImageUrl) { + mappedValue.backgroundImageUrl = variant.options[this.field].backgroundImageUrl; } if (this.config.mappings && this.config.mappings && this.config.mappings[value.toString().toLowerCase()]) { @@ -580,14 +585,7 @@ export class Variant { public type = 'variant'; public available: boolean; public attributes: Record = {}; - public options: Record< - string, - { - value: string; - attributeId?: string; - optionId?: string; - } - >; + public options: VariantDataOptions; public mappings: SearchResponseModelResultMappings = { core: {}, From 0d3779cafe8829739b04c79348f22725d9b30878 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 28 May 2024 11:33:38 -0600 Subject: [PATCH 2/2] fix(store-mobx/searchresultstore): adding background property to variant options data --- .../snap-store-mobx/src/Search/Stores/SearchResultStore.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts b/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts index b246c1b4c..b7e2caed5 100644 --- a/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts +++ b/packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts @@ -126,6 +126,7 @@ export type VariantDataOptions = Record< string, { value: string; + background?: string; backgroundImageUrl?: string; attributeId?: string; optionId?: string; @@ -512,6 +513,10 @@ export class VariantSelection { mappedValue.backgroundImageUrl = variant.options[this.field].backgroundImageUrl; } + if (variant.options[this.field].background) { + mappedValue.background = variant.options[this.field].background; + } + if (this.config.mappings && this.config.mappings && this.config.mappings[value.toString().toLowerCase()]) { const mapping = this.config.mappings[value.toString().toLowerCase()];