Sorting Products By Custom Fields

The Miva admin allows customers to sort a list of products such as a category or search results page by a custom product field.

For example, if you have a custom product field called Brand you can now make brand a sortable value similar or how customers already can sort the products by price, name, code or bestselling. This is different from a facet or filter which limits the results to only show products matching that selected facet. When you sort by a custom field, the entire result set is displayed, just sorted ascending or descending by the custom field you selected.


Custom Field Sort


On this Page

Setup & Configuration

To enable sorting by custom fields you need to modify your page template on CTGY or SRCH to add the custom fields to your sort by select input. The default code looks like below. In this example "tea_caffine" is the custom product field code.


There are two options sorting custom fields, either ascending or descending. You can choose to only use one, or both. The first sort option sorts the products accending and the second option which has "customfield_desc:" is the decending sort.

Note

Sorting by custom fields is currently supported on CTGY & SRCH. It is not currently supported on ReadyTheme Product Listing Components.

Point & Click Settings

There are admin UI settings in point in click mode which will automatically output the code needed in the page template. However, this does rewrite the page template back to default CSSUI. This can be useful to generate the code you need, then copy and paste it into your themes template.

Custom Field Sort


Default Sort Method

Now that custom fields are sortable fields on product lists, you can also set the default sort for when the page loads to be one of them. Just keep in mind, this does have a negative impact on overall page load performance compared to the default sort.

Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

Accept

Copyright © 1997 – 2021 Miva©, Miva Merchant©, MivaPay©, MivaCon© Miva, Inc. All Rights Reserved.