In this topic we are going to discuss about Steps to create custom facet
Step 1:
Create one attribute myColor to Product in items.xml as follows in *core-items.xml.
<itemtype code="Product" autocreate="false" generate="false">
<attributes>
<attribute type="java.Lang.String" qualifier="myColor">
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
Step 2:
Do ant and start the server and do system update.
Step 3:
Create one solrIndexedProperty in solr.impex as follows
#
# Import the Solr configuration for the training store.
#
$productCatalog=trainingProductCatalog
$catalogVersions=catalogVersions(catalog(id),version);
$serverConfigName=trainingSolrServerConfig
$indexConfigName=trainingSolrindexConfig
$searchConfigName=trainingPageSize
$facetSearchConfigName=trainingIndex
$facetSearchConfigDescription=TrainingSolrIndex
$searchIndexNamePrefix=training
$solrIndexedType=trainingProductType
$indexBaseSite=training
$indexLanguages=ja,en,de,zh
$indexCurrencies=JPY,USD
#facet properties
INSERT_UPDATE
SolrIndexedProperty;solrIndexedType(identifier)[unique=true];name[unique=true];tyoe(code);sortableType(code);currency[default=false];localized[default=false];multiValue[default=false];useForSpellchecking[default=false];useForAutocomplete[default=false];facet;fieldValueProvider;valueProviderParameter
;$solrIndexedType;myColor ;string; ; ; ; ;true;true;true
Step 4:
Go to Backoffice –>Facet Search–>Solr Item Types.
Select trainingIndex and then check whether Custom facet property is created or not .
Step 5:
Assign color value for products through the following impex.
$lang=en
$contentCatalog=trainingProductCatalog
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Online])[default=$contentCatalog:Online]
INSERT_UPDATE Product;$contentCV;code[unique=true];name[lang=$lang];myColor
; ;552 ;myProduct;Red
; ;553 ;myProduct1;Silver
We can also add Data for myColor to the products directly in Backoffice also.
Step 6:
Now facet will be created in filter section on PLP page
![](https://hybris.blog/wp-content/uploads/2023/06/screenshot-.png?w=1024)
Leave a comment