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(core): use categoryEntityId filter on category PLP #880

Merged
merged 1 commit into from
May 8, 2024
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
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
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
Loading