Skip to content
Merged
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
11 changes: 11 additions & 0 deletions vtex/loaders/intelligentSearch/productListingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ const selectPriceFacet = (facets: Facet[], selectedFacets: SelectedFacet[]) => {
}
return facets;
};

const hasInvalidCategorySegment = (allPageTypes: PageType[]): boolean => {
return allPageTypes.some((pageType) => pageType.pageType === "NotFound");
};

/**
* @title Product Listing Page - Intelligent Search
* @description List a product listing page, with products, filters, sort and SEO data, commonly used for category, search, brand and collection pages.
Expand Down Expand Up @@ -334,6 +339,12 @@ const loader = async (
}

const allPageTypes = await pageTypesFromUrl(pathToUse, ctx);

if (hasInvalidCategorySegment(allPageTypes)) {

return null;
}

const pageTypes = getValidTypesFromPageTypes(allPageTypes);

const selectedFacets = baseSelectedFacets.length === 0
Expand Down
Loading