From 431c364107809098ffef2dc7af82d56e7a0e79c5 Mon Sep 17 00:00:00 2001 From: casperiv <53900565+casperiv0@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:14:12 +0100 Subject: [PATCH] chore: remove debug changes --- .../entities/search-index-item.entity.ts | 2 +- .../indexer/indexer.controller.ts | 33 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/packages/core/src/plugin/default-search-plugin/entities/search-index-item.entity.ts b/packages/core/src/plugin/default-search-plugin/entities/search-index-item.entity.ts index d8b314e507..2c9c38baf6 100644 --- a/packages/core/src/plugin/default-search-plugin/entities/search-index-item.entity.ts +++ b/packages/core/src/plugin/default-search-plugin/entities/search-index-item.entity.ts @@ -91,6 +91,6 @@ export class SearchIndexItem { inStock?: boolean; // Added dynamically based on the `indexStockStatus` init option. productInStock?: boolean; - // Added dynamically based TODO + // Added dynamically based on the `indexCurrencyCode` init option. currencyCode?: CurrencyCode; } diff --git a/packages/core/src/plugin/default-search-plugin/indexer/indexer.controller.ts b/packages/core/src/plugin/default-search-plugin/indexer/indexer.controller.ts index 009bf68a75..7fefeb6919 100644 --- a/packages/core/src/plugin/default-search-plugin/indexer/indexer.controller.ts +++ b/packages/core/src/plugin/default-search-plugin/indexer/indexer.controller.ts @@ -444,20 +444,17 @@ export class IndexerController { const ch = new Channel({ ...channel, defaultCurrencyCode: currencyCode }); ctx.setChannel(ch); - const mutatedVariant = await this.productPriceApplicator.applyChannelPriceAndTax( - variant, - ctx, - ); + await this.productPriceApplicator.applyChannelPriceAndTax(variant, ctx); const item = new SearchIndexItem({ channelId: ctx.channelId, languageCode, currencyCode, - productVariantId: mutatedVariant.id, - price: mutatedVariant.price, - priceWithTax: mutatedVariant.priceWithTax, - sku: mutatedVariant.sku, - enabled: product.enabled === false ? false : mutatedVariant.enabled, + productVariantId: variant.id, + price: variant.price, + priceWithTax: variant.priceWithTax, + sku: variant.sku, + enabled: product.enabled === false ? false : variant.enabled, slug: productTranslation?.slug ?? '', productId: product.id, productName: productTranslation?.name ?? '', @@ -467,20 +464,16 @@ export class IndexerController { productPreviewFocalPoint: product.featuredAsset ? product.featuredAsset.focalPoint : null, - productVariantPreviewFocalPoint: mutatedVariant.featuredAsset - ? mutatedVariant.featuredAsset.focalPoint - : null, - productVariantAssetId: mutatedVariant.featuredAsset - ? mutatedVariant.featuredAsset.id + productVariantPreviewFocalPoint: variant.featuredAsset + ? variant.featuredAsset.focalPoint : null, + productVariantAssetId: variant.featuredAsset ? variant.featuredAsset.id : null, productPreview: product.featuredAsset ? product.featuredAsset.preview : '', - productVariantPreview: mutatedVariant.featuredAsset - ? mutatedVariant.featuredAsset.preview - : '', + productVariantPreview: variant.featuredAsset ? variant.featuredAsset.preview : '', channelIds: channelIds.map(x => x.toString()), facetIds: this.getFacetIds(variant, product), facetValueIds: this.getFacetValueIds(variant, product), - collectionIds: mutatedVariant.collections.map(c => c.id.toString()), + collectionIds: variant.collections.map(c => c.id.toString()), collectionSlugs: collectionTranslations.map(c => c?.slug).filter(notNullOrUndefined) ?? [], }); @@ -489,14 +482,14 @@ export class IndexerController { 0 < (await this.productVariantService.getSaleableStockLevel(ctx, variant)); const productInStock = await this.requestContextCache.get( ctx, - `productVariantsStock-${mutatedVariant.productId}`, + `productVariantsStock-${variant.productId}`, () => this.connection .getRepository(ctx, ProductVariant) .find({ loadEagerRelations: false, where: { - productId: mutatedVariant.productId, + productId: variant.productId, deletedAt: IsNull(), }, })