File tree Expand file tree Collapse file tree
core/app/[locale]/(default)/(faceted)/category/[slug] Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @bigcommerce/catalyst-core " : minor
3+ ---
4+
5+ Respect default product search sort and product category sort settings from the control panel.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const CategoryPageQuery = graphql(
1212 category(entityId: $entityId) {
1313 entityId
1414 name
15+ defaultProductSort
1516 ...BreadcrumbsFragment
1617 seo {
1718 pageTitle
Original file line number Diff line number Diff line change @@ -127,6 +127,11 @@ export default async function Category(props: Props) {
127127
128128 const taxDisplay = settings ?. tax ?. plp ;
129129
130+ const categoryDefaultSort =
131+ category . defaultProductSort && category . defaultProductSort !== 'DEFAULT'
132+ ? category . defaultProductSort . toLowerCase ( )
133+ : 'featured' ;
134+
130135 const streamableFacetedSearch = Streamable . from ( async ( ) => {
131136 const searchParams = await props . searchParams ;
132137 const currencyCode = await getPreferredCurrencyCode ( ) ;
@@ -136,12 +141,14 @@ export default async function Category(props: Props) {
136141 customerAccessToken ,
137142 ) ;
138143 const parsedSearchParams = loadSearchParams ?.( searchParams ) ?? { } ;
144+ const sort = typeof searchParams . sort === 'string' ? searchParams . sort : categoryDefaultSort ;
139145
140146 const search = await fetchFacetedSearch (
141147 {
142148 ...searchParams ,
143149 ...parsedSearchParams ,
144150 category : categoryId ,
151+ sort,
145152 } ,
146153 currencyCode ,
147154 customerAccessToken ,
@@ -269,7 +276,7 @@ export default async function Category(props: Props) {
269276 resetFiltersLabel = { t ( 'FacetedSearch.resetFilters' ) }
270277 showCompare = { productComparisonsEnabled }
271278 showRating = { showRating }
272- sortDefaultValue = "featured"
279+ sortDefaultValue = { categoryDefaultSort }
273280 sortLabel = { t ( 'SortBy.sortBy' ) }
274281 sortOptions = { [
275282 { value : 'featured' , label : t ( 'SortBy.featuredItems' ) } ,
You can’t perform that action at this time.
0 commit comments