Configure the order of facets
Oracle Commerce uses faceted navigation to support shoppers navigating on the storefront. The facets are returned in a defined order, which you can change with either the administration console or Admin API.
Facets are also returned dynamically, meaning if the results in the response contain appropriate data and that data can change the results. For example, a Brand facet is not returned if either no products had a brand, or all products had the same brand. If you want to hide a facet in certain situations, you can exclude it from the list for those situations and set the showAll
flag to false
.
This section describes how to configure the order of facets with the Admin API. To use the administration interface to perform this task instead, see Refine and order search results.
Note: Some Commerce REST APIs use the term dimension instead of facet, but the two are interchangeable from a functional perspective.
Specify a custom order for facets
To specify a non-default display order for selected facets in your application, follow these steps:
- Use one of the following endpoints to export configuration of the Guided Navigation catalog in JSON format or in ZIP format:
GET /gsadmin/v1/cloud/content/facets/default (JSON format)
GET /gsadmin/v1/cloud/content/facets/default.zip (ZIP format)
The default configuration of the Guided Navigation content item is returned. The
navigation[]
attribute is empty. When the navigation attribute is empty, the facets in the refinements list are not explicitly ordered; instead, they appear in an order determined by the system. For information about the attributes in this configuration, see Attributes of the Guided Navigation Content Item. - In the navigation attribute, include a
RefinementMenu
element for each facet that you want to include among the explicitly ordered facets. Arrange theRefinementMenu
elements in the order in which you want the corresponding facets to appear. See Example of custom facet ordering. - Use one of the following endpoints to import configuration of the Guided Navigation content item in JSON format or in ZIP format:
PUT /gsadmin/v1/cloud/content/facets/default (JSON format)
PUT /gsadmin/v1/cloud/content/facets/default.zip (ZIP format)
Note: If the
GuidedNavigation
content item does not exist, you must use the POST method to create it. You cannot, however, use POST to update an existing content item. - View the changes in your Preview environment to verify that they are correct.
- Publish your catalog to promote your changes to your production environment.
Example of custom facet ordering
For example, if you want the four following facets to appear in the order Category
, Price Range
, Brand
, and Color
, modify the navigation[]
attribute as follows:
"navigation": [
{
"@type": "RefinementMenu",
"dimensionName": "product.category"
},
{
"@type": "RefinementMenu",
"dimensionName": "product.priceRange"
},
{
"@type": "RefinementMenu",
"dimensionName": "product.brand"
},
{
"@type": "RefinementMenu",
"dimensionName": "product.color"
}
]
Attributes of the Guided Navigation Content Item
The following table summarized that attributes of the GuidedNavigation
content item.
Attribute | Value |
---|---|
@type |
Required. Must be set to GuidedNavigation |
@name |
Optional. A name for this rule that is displayed in tools. |
showAll |
Optional. False limits the facets included in the refinements list to those included in the |
navigation |
Required. A list of facet objects. Each facet object has the following:
In the refinements list, the facets appear in the order in which the facet objects are listed in the navigation attribute. |
triggers |
Not applicable. Do not change default. |
priority |
Not applicable. Do not change default. |