\FacetHelper
Adds methods for limited kinds of faceting using the silverstripe ORM.
This is used by the default ShopSearchSimple adapter but also can
be added to other contexts (such as ProductCategory).
TODO: Facet class + subclasses
- Author: Mark Guinn <mark@adaircreative.com>
Synopsis
class FacetHelper
extends Object
{
- // members
- private static bool $faster_faceting = false;
- private static bool $sort_facet_values = true;
- private static string $attribute_facet_regex = '/^ATT(\d+)$/';
- private static bool $default_checkbox_state = true;
- // methods
- public static FacetHelper inst()
- public array scrubFilters()
- public DataList addFiltersToDataList()
- public array processFilterField()
- public array expandFacetSpec()
- public ArrayList buildFacets()
- protected void buildAttributeFacet()
- protected array buildAllAttributeFacets()
- public ArrayList insertFacetLinks()
- protected array getRecursiveChildValues()
- public ArrayList updateFacetState()
- protected bool updateCheckboxFacetState()
- public ArrayList transformHierarchies()
Hierarchy
Extends
- Object
Members
private
Methods
protected
- buildAllAttributeFacets() — Builds facets from all attributes present in the data set.
- buildAttributeFacet() — NOTE: this will break if applied to something that's not a SiteTree subclass.
- getRecursiveChildValues()
- updateCheckboxFacetState() — For checkboxes, updates the state based on filters. Handles hierarchies and FilterOnlyLeaves
public
- addFiltersToDataList()
- buildFacets() — This is super-slow. I'm assuming if you're using facets you probably also ought to be using Solr or something else. Or maybe you have unlimited time and can refactor this feature and submit a pull request...
- expandFacetSpec() — Processes the facet spec and removes any shorthand (field => label).
- insertFacetLinks() — Inserts a "Link" field into the values for each facet which can be used to get a filtered search based on that facets
- inst()
- processFilterField()
- scrubFilters() — Performs some quick pre-processing on filters from any source
- transformHierarchies() — If there are any facets (link or checkbox) that have a HierarchyDivider field in the spec, transform them into a hierarchy so they can be displayed as such.
- updateFacetState() — For checkbox and range facets, this updates the state (checked and min/max) based on current filter values.