File tree Expand file tree Collapse file tree
core/app/[locale]/(default)/(faceted)/search Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ const SearchPageQuery = graphql(`
2727 tax {
2828 plp
2929 }
30+ search {
31+ defaultSearchProductSort
32+ }
3033 }
3134 }
3235 }
Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ export default async function Search(props: Props) {
8585
8686 const taxDisplay = settings ?. tax ?. plp ;
8787
88+ const defaultProductSort = settings ?. search . defaultSearchProductSort ;
89+
8890 const streamableFacetedSearch = Streamable . from ( async ( ) => {
8991 const searchParams = await props . searchParams ;
9092 const customerAccessToken = await getSessionCustomerAccessToken ( ) ;
@@ -95,11 +97,13 @@ export default async function Search(props: Props) {
9597 customerAccessToken ,
9698 ) ;
9799 const parsedSearchParams = loadSearchParams ?.( searchParams ) ?? { } ;
100+ const sort = typeof searchParams . sort === 'string' ? searchParams . sort : defaultProductSort ;
98101
99102 const search = await fetchFacetedSearch (
100103 {
101104 ...searchParams ,
102105 ...parsedSearchParams ,
106+ sort,
103107 } ,
104108 currencyCode ,
105109 customerAccessToken ,
@@ -258,7 +262,7 @@ export default async function Search(props: Props) {
258262 resetFiltersLabel = { t ( 'FacetedSearch.resetFilters' ) }
259263 showCompare = { productComparisonsEnabled }
260264 showRating = { showRating }
261- sortDefaultValue = " featured"
265+ sortDefaultValue = { defaultProductSort ?. toLowerCase ( ) ?? ' featured' }
262266 sortLabel = { t ( 'SortBy.sortBy' ) }
263267 sortOptions = { [
264268 { value : 'featured' , label : t ( 'SortBy.featuredItems' ) } ,
You can’t perform that action at this time.
0 commit comments