Skip to content

Commit

Permalink
fix(core): use categoryEntityId filter on category PLP (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini committed May 8, 2024
1 parent 613677c commit af61999
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-swans-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Category pages now use the `categoryEntityId` filter
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const Facets = ({ facets, pageType }: Props) => {
aria-labelledby={labelId}
defaultChecked={category.isSelected}
id={id}
name="category"
name="categoryIn"
onCheckedChange={submitForm}
value={category.entityId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const mapFacetsToRefinements = ({ facets, pageType }: Props) =>
return facet.categories
.filter((category) => category.isSelected)
.map<FacetProps<PublicParamKeys>>(({ name, entityId }) => ({
key: 'category',
key: 'categoryIn',
display_name: name,
value: String(entityId),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default async function Category({ params: { locale, slug }, searchParams
const messages = await getMessages({ locale });

const categoryId = Number(slug);
const search = await fetchFacetedSearch({ ...searchParams, category: [slug] });
const search = await fetchFacetedSearch({ ...searchParams, category: categoryId });

const data = await getCategoryPageData({
categoryId,
Expand Down
7 changes: 5 additions & 2 deletions core/app/[locale]/(default)/(faceted)/fetch-faceted-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export const PublicSearchParamsSchema = z.object({
after: z.string().optional(),
before: z.string().optional(),
brand: SearchParamToArray.transform((value) => value?.map(Number)),
category: SearchParamToArray.transform((value) => value?.map(Number)),
category: z.coerce.number().optional(),
categoryIn: SearchParamToArray.transform((value) => value?.map(Number)),
isFeatured: z.coerce.boolean().optional(),
limit: z.coerce.number().optional(),
minPrice: z.coerce.number().optional(),
Expand Down Expand Up @@ -108,6 +109,7 @@ export const PublicToPrivateParams = PublicSearchParamsSchema.catchall(SearchPar
const {
brand,
category,
categoryIn,
isFeatured,
minPrice,
maxPrice,
Expand Down Expand Up @@ -137,7 +139,8 @@ export const PublicToPrivateParams = PublicSearchParamsSchema.catchall(SearchPar
sort,
filters: {
brandEntityIds: brand,
categoryEntityIds: category,
categoryEntityId: category,
categoryEntityIds: categoryIn,
hideOutOfStock: stock?.includes('in_stock'),
isFreeShipping: shipping?.includes('free_shipping'),
isFeatured,
Expand Down

0 comments on commit af61999

Please sign in to comment.