Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] - Remove the override from props in fq #1036

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 13 additions & 3 deletions vtex/loaders/legacy/productListingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ const loader = async (
IS_TO_LEGACY[url.searchParams.get("sort") ?? ""] ??
props.sort ??
sortOptions[0].value;
const fq = props.fq ? [props.fq] : url.searchParams.getAll("fq");
const fq = [
...new Set([
...(props.fq ? [props.fq] : []),
...url.searchParams.getAll("fq"),
]),
];
const _from = page * count;
const _to = (page + 1) * count - 1;

Expand Down Expand Up @@ -441,7 +446,12 @@ export const cacheKey = (props: Props, req: Request, ctx: AppContext) => {
if (url.searchParams.has("ft")) {
return null;
}

const fq = [
...new Set([
...(props.fq ? [props.fq] : []),
...url.searchParams.getAll("fq"),
]),
];
const segment = getSegmentFromBag(ctx)?.token ?? "";
const params = new URLSearchParams([
["term", props.term ?? url.pathname ?? ""],
Expand All @@ -454,7 +464,7 @@ export const cacheKey = (props: Props, req: Request, ctx: AppContext) => {
props.sort ?? "",
],
["filters", props.filters ?? ""],
["fq", props.fq ?? url.searchParams.getAll("fq").join(",") ?? ""],
["fq", fq.join(",") ?? ""],
[
"ft",
props.ft ?? url.searchParams.get("ft") ?? url.searchParams.get("q") ?? "",
Expand Down
Loading