Select and Configure Sort Fields

Using a sort field, shoppers can sort search results by that field instead of the default relevance field. It’s not always clear which fields you should use for sorting, but make sure all your item records have data in the fields you pick—especially if those fields are optional. Items with empty fields show up last when you sort by that field. For example, if you sort by price, items with no price will be at the end.

Note:

Relevance is always the default sort field, and you can’t remove it. But you can add other item fields as sorting options for your site. By default, the onlinecustomerprice field is already set up as a sort option, so you don’t need to do any configuration to let shoppers sort by price. Commerce web stores are pre-configured to display two price sorting options: low to high and high to low.

When you add a Sort Field under Search Index, you turn on sorting for that field. You can use it with the Item Search API, but it only shows up in your web store 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. Choose the item attributes you want shoppers to use for sorting.

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

    • Sort Order — Choose ascending or descending order. This sets how products are sorted in the 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 you want to configure from the Select Website list.

  3. Select the specific domain 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 you’ve set up a custom field like custitem41 as a sort field, you’ll need to add it to the Desktop, Phone, and Tablet sections before shoppers can use it on those devices.

  7. Click Save.

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

For example, if you’ve set up custitem41 as a sort field, add it to the sortOptions array before it shows up in your 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

General Notices