diff --git a/manifest.json b/manifest.json index b3c60d5..cf874dd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "vendor": "vtex", "name": "adserver-resolver", - "version": "2.10.0", + "version": "2.10.1", "title": "Ad Server Resolver", "description": "Configurations for sponsored products on your store", "builders": { diff --git a/node/utils/shouldFetchSponsoredProducts.ts b/node/utils/shouldFetchSponsoredProducts.ts index 8bdd7a0..141e5eb 100644 --- a/node/utils/shouldFetchSponsoredProducts.ts +++ b/node/utils/shouldFetchSponsoredProducts.ts @@ -21,6 +21,10 @@ const shouldFetchOnProductClusers = async (ctx: Context) => { return settings?.enableAdsOnCollections ?? true } +const isFirstPage = (args: SearchParams) => { + return args.page === undefined || args.page.toString() === '1' +} + /** * Determine whether or not to fetch sponsored products based on a few parameters: * 1. If the search is not sorted by relevance, don't fetch. @@ -32,7 +36,11 @@ export const shouldFetchSponsoredProducts = async ( ctx: Context ) => { if (!isSortedByRelevance(args)) return false - if (!queryHasProductClusters(args)) return true + if (!isFirstPage(args)) return false + + if (!queryHasProductClusters(args)) { + return true + } return shouldFetchOnProductClusers(ctx) }