Skip to content

Commit

Permalink
Merge pull request #1060 from searchspring/variant-option-backgroundi…
Browse files Browse the repository at this point in the history
…mageurl

Variant Option `backgroundimageurl`
  • Loading branch information
korgon authored May 28, 2024
2 parents 58f1b1c + 0d3779c commit f76b195
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions packages/snap-store-mobx/src/Search/Stores/SearchResultStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,20 @@ export class Banner {
export type VariantData = {
mappings: SearchResponseModelResultMappings;
attributes: Record<string, unknown>;
options: Record<
string,
{
value: string;
attributeId?: string;
optionId?: string;
}
>;
options: VariantDataOptions;
};

export type VariantDataOptions = Record<
string,
{
value: string;
background?: string;
backgroundImageUrl?: string;
attributeId?: string;
optionId?: string;
}
>;

type ProductMinimal = {
id: string;
attributes: Record<string, unknown>;
Expand Down Expand Up @@ -505,6 +509,12 @@ 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 (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()]) {
Expand Down Expand Up @@ -580,14 +590,7 @@ export class Variant {
public type = 'variant';
public available: boolean;
public attributes: Record<string, unknown> = {};
public options: Record<
string,
{
value: string;
attributeId?: string;
optionId?: string;
}
>;
public options: VariantDataOptions;

public mappings: SearchResponseModelResultMappings = {
core: {},
Expand Down

0 comments on commit f76b195

Please sign in to comment.