diff --git a/packages/core/src/service/services/product-variant.service.ts b/packages/core/src/service/services/product-variant.service.ts index 585e9e1c0a..c7e816c488 100644 --- a/packages/core/src/service/services/product-variant.service.ts +++ b/packages/core/src/service/services/product-variant.service.ts @@ -274,8 +274,12 @@ export class ProductVariantService { * for purchase by Customers. */ async getSaleableStockLevel(ctx: RequestContext, variant: ProductVariant): Promise { - // TODO: Use caching (RequestContextCacheService) to reduce DB calls - const { outOfStockThreshold, trackInventory } = await this.globalSettingsService.getSettings(ctx); + const { outOfStockThreshold, trackInventory } = await this.requestCache.get( + ctx, + 'globalSettings', + () => this.globalSettingsService.getSettings(ctx), + ); + const inventoryNotTracked = variant.trackInventory === GlobalFlag.FALSE || (variant.trackInventory === GlobalFlag.INHERIT && trackInventory === false); @@ -581,7 +585,7 @@ export class ProductVariantService { }); } const { taxZoneStrategy } = this.configService.taxOptions; - const zones = this.zoneService.findAll(ctx); + const zones = this.requestCache.get(ctx, 'allZones', () => this.zoneService.findAll(ctx)); const activeTaxZone = await this.requestCache.get(ctx, 'activeTaxZone', () => taxZoneStrategy.determineTaxZone(ctx, zones, ctx.channel, order), );