Many e-commerce sites have a large number of campaigns and promotions running. Facets in Optimizely Customized Commerce let users apply filters to campaigns and discounts (promotions), for easier location of specific items in the **Campaign** view.
Key components mentioned here are available in the EPiServer.Commerce.Shell.Facets namespace.
FacetGroup contains properties that identify a group of items by which to filter a campaign and settings to configure a group. Initialize a FacetGroup through a constructor.
## FacetGroup settings
FacetGroupSettings contains properties to configure a facet group. Initialize these properties through a constructor.
FacetItem contains properties that identify a facet item in the facet group, which is a value to a filtered campaign. Initialize these properties through a constructor.
## Custom facets Commerce 12.10 and higher
To customize facet groups, create a class inheriting from FacetGroupModifier, then register it on one of your initialization modules.
**Example:** Displaying four markets by default in the market facet group, instead of three.
**Example:** Registering the facet.
## Custom facets Commerce 12.9 and lower
First, you need a custom facet based on a campaign facet. Here we create a custom facet that:
Clears all built-in groups.
Has a facet group that filters by a campaign's last modified date. This user can choose last modified day, week, or month.
This example shows that the last modified facet group is single selection with three options: day, week, or month.
To show a item numbers that indicate how many campaigns are filtered, in FacetGroupSettings, set showMatchingItemsto **true**.
To use a CustomFacet, follow these steps.
Create a rest store named "**customfacet**" that returns a custom facet.
To show matching items, use the facet query handler to calculate matching numbers.
Register the custom facet store and override the existing store "**epi.commerce.facet**". Create a module initializer. If an initializer exists, edit it.
If you do not register a module initializer, you need to update or create the project's _module.config_ file, as shown in the example below.
After following the steps above, the **Campaign** view has a custom facet on the left side, and the built-in groups have disappeared. We can interact in the UI, but still need to filter campaigns.
Create a function to filter campaigns by last modified date, based on GetContentsByFacet.
Customize the query to return GetCampaignsByLastModified, by overriding GetSalesCampaignChildrenQuery.
Here is an example of the customized **Campaign** view.