Select and Configure Sort Fields

Using a sort field, a shopper can sort the search results by that field instead of the default relevance field. It may not always be obvious on which field you should or should not sort, but you need to ensure that all item records contain data for the fields you choose as sort fields, especially if you select an item record field where values are optional. Items with empty fields are placed last when sorting by that field. For example, when sorting by price, the search service will place items that have no price last.

Note:

Relevance is the default sort field, and you cannot remove Relevance from the list. But you can select other item fields to use as sorting options for your site. By default, the onlinecustomerprice field is added as an additional sort option, and additional configuration is not required to support sorting by price. Commerce web stores are pre-configured to display two pricing options: Sort by price, low to high and Sort by price, high to low.

Adding a Sort Field under Search Index enables sorting for that field. You can then use this sort field with the Item Search API but the sort field is visible in the web store only after you configure it.

To add the sort fields:

  1. Complete the prerequisite tasks as described in Prerequisites.

  2. Go to Commerce > Websites > Website List.

  3. Click Edit next to your SuiteCommerce Advanced site.

  4. Click the Search Index subtab and then Sort Fields.

    • Field Name — (Required) Select an item record field. Select item attributes that you want shoppers to use for sorting search results.

    • Field ID — (View only field) Displays the field's internal ID.

    • Sort Order — Choose ascending or descending order. This is the order in which products are sorted in search results.

After you select the sort fields, you can configure the sort fields for your Commerce web stores using the SuiteCommerce Configuration record. Configuring a Sort Field ensures that the sort field is available to the shoppers in the web store.

To configure the sort fields:

  1. Select the domain to configure at Commerce > Websites > Configuration.

  2. Select the site that you want to configure from the Select Website list.

  3. Select the specific domain that you want to configure from the Select Domain list.

  4. Click Configure.

  5. On the SuiteCommerce Configuration record page, click the Search tab and then click the Result Sorting subtab.

  6. Define and configure your sort options. For details, see Result Sorting Subtab.

    For example, if a custom field, custitem41 has been defined as a sort field in the web site record, a line item for that field must be added to the Desktop, Phone, and Tablet sections before the selection is available in the web store on the applicable device.

  7. Click Save.

To configure sort fields for pre-Vinson SuiteCommerce Advanced implementations, the sortOptions array in the SC.Shopping.Configuration.js configuration file must be extended to include the new sort field. For guidance on extending your implementation, see Develop Your SCA Customization.

For example, if a custom field custitem41 has been configured as a sort field in the web site record, a line item for that field must be added to the sortOptions array before the selection is available on the web store.

          sortOptions: [
   {id: 'relevance:asc', name: _('Sort by relevance').translate(), isDefault: true}
,   {id: 'onlinecustomerprice:asc', name: _('Sort by price, low to high').translate()}
,   {id: 'onlinecustomerprice:desc', name: _('Sort by price, high to low ').translate()}
,   {id: 'custitem41:desc', name: _('Sort by best seller, low to high ').translate()}
] 

        

For information about handling Matrix Item sorting and combining Sort Fields using the Item Search API, see Sorting Best Practices.

Related Topics

Select and Configure Facet Fields
Select and Configure Sort Fields
Define Field Sets
Search Settings Overview

General Notices