, Search and filter on your custom product attributes in SAP Hybris Commerce, Acorel
Gratis demo
, Search and filter on your custom product attributes in SAP Hybris Commerce, Acorel

Search and filter on your custom product attributes in SAP Hybris Commerce

Mark Kilsdonk

Adding custom attributes to the products in your SAP Hybris Commerce shop is a relatively easy task. Next step would be to make these attributes part of the product search in your shop to enable filtering and searching on the contents of these attributes.

This blog describes the relevant steps to define custom product attributes and add them to your shop search.

The Electronics demo store, as part of the standard accelerator of SAP Hybris Commerce, has been used as the basis for this blog, but the same steps should work for all SAP Hybris Commerce based shops using the SOLR search.

Obviously, performing these steps will have a direct impact on product content and search results provided in the shop. Our strong advise is to try these steps first on your test shop for verification before applying them your live/online shop.

Define product attributes

There are several ways to add your own attributes to the products in SAP Hybris Commerce. Cleanest solution is to define a classification catalog, add a classification category structure with attributes per category and assign products from your product catalog.

For this blog, we have extended the existing Electronics classification catalog with an additional category ‘Acorel Blog Attributes’. This category consist of a single feature being our custom product attribute for this blog called ‘Acorel Attribute 1’. The following screenshot shows how one can set name, type and characteristics for a feature. In this example we have used a simple string type for our custom attribute.

Once this classification definition step has been done, we have added some products from the Electronics product catalog to the same classification category. By doing so, our feature is immediately available as a product attribute on these products. The following screenshot shows that our ‘Acorel Attribute 1’ is available on one of the products.
Re-publishing this product will update the product contents on the demo shop. The new product attribute is then directly showing in our classification category on the Electronics store.

Add an product attribute to the SOLR search

Next step is making our custom attribute known in the search engine so that we search and filter on its contents. SAP Hybris Commerce uses the SOLR search engine by default and a lot of its settings can be customized from the SAP Hybris Commerce BackOffice cockpit.

Login to the BackOffice cockpit as an administrator and select from the menu:
System -> Search and Navigation -> Indexed Types

A list of indexed types is presented in which you have to select the indexed type that is related to your shop (usually there is one indexed type for each shop). The detail page of the indexed type includes a indexed properties tab where all product attributes are listed that are part of this search index.

One can add a new property from the same tab. The initial create wizard is a bit limited in the fields available, but if you choose to edit the details for the newly added property, the following pop-up edit page is showing with all relevant fields.

The ‘Indexed Property’ tab is showing the main characteristics where we have to provide an ID and assign the property to our classification category ‘Acorel Blog Attributes’. There are several others indicators to define the search behavior. For example, the auto-complete setting will trigger the auto completion of our search term in the free text search in the shop.

The lower part of this tab enables us to select a property value provider. A number of default providers are available for selection, but the ‘classificationPropertySplitValueProvider’ was directly working in our demo shop.

The ‘Free Text Query’ tab offers the indicators to set the behavior of this property when using the free text search in the shop. Setting it to true will make the contents of our product attribute part of the free search on the shop. Setting a boost factor will boost the products up in the list of presented search results if there is a match with the contents of the product attribute. The same settings can be done for fuzzy, wildcard and phrase queries.

The ‘Facet Settings’ tab enables us to define a facet for our product attribute. Facets are used in SAP Hybris Commerce to filter on a product listing resulting from a product search or product category selection. The indicators on this tab define the behavior of the facet. For example, one can set the selection type (e.g. a single- or multi-select) and the sorting of the filter options.

The indexed type will need to be (re-)indexed to SOLR to make this additional property available. Usually there is a daily (off business hours!) job scheduled to do this.

Testing the end result

When we move back to the Electronics demo store, our ‘Acorel Attribute 1’ product attribute is now showing as a filter option in the ‘Blog Attribute 1’ facet. Selecting one of the presented filter values will narrow down the search results to the products containing this custom product attribute value.

The contents of this product attribute can also be searched for from the free text search box on the Electronics store.

, Search and filter on your custom product attributes in SAP Hybris Commerce, Acorel

Mark Kilsdonk