Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
10 changes: 9 additions & 1 deletion node/utils/shouldFetchSponsoredProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Comment thread
rodorgas marked this conversation as resolved.
}

/**
* 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.
Expand All @@ -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)
}
Loading