Page 1 of 1

Re: Add New Filters

Posted: Fri Jul 05, 2013 7:03 pm
by bpolster
Take a look at the demo site sample SQL (load_catalog_data.sql) to see how we are adding to the BLC_SEARCH_FACET entity. You can associate search facets with categories to achieve what you are trying to do. In the heat clinic demo, we give an example of this with the "heat_factor" in the hot sauces category.

Re: Add New Filters

Posted: Fri Jul 12, 2013 1:59 am
by ankitpatni
This is a commercial feature of broadleaf commerce if you want to enable this through Admin,whereas if you are good to go with SOLR and DB then you can create this using sql scripts also.

Steps For Creating a New Facet Filter :
1. Create a Product Attribute On the basis of what filter you want to create,in load_catalog_data.sql(Demosite>Core>src>main>resources>sql>load_catalog_data.sql)
Script for this is-
Lets say creating a Length filter for the Shirts in Broadleaf Demosite

Code: Select all

INSERT INTO BLC_PRODUCT_ATTRIBUTE (PRODUCT_ATTRIBUTE_ID, PRODUCT_ID, NAME, VALUE) VALUES (20,100,'Length',31);

Enter this script for each and every product of the category.

2. Now create an entry of this product attribute in BLC_FIELD.
As per the above example the script will be like this-

Code: Select all

INSERT INTO BLC_FIELD (FIELD_ID, ENTITY_TYPE, PROPERTY_NAME, ABBREVIATION, SEARCHABLE, FACET_FIELD_TYPE) VALUES (8, 'PRODUCT',productAttributes.Length', 'length', 0, 'i');

For reference to the FACET_FIELD_TYPE check out the schema.xml(Demosite>site>main>resource>schema.xml)
This file has definition of each and every facet field types.

3. After this make entries for the above FIELD_ID in “BLC_SEARCH_FACET” and ‘BLC_CAT_SEARCH_FACET_XREF’ using the following script-

Code: Select all

INSERT INTO BLC_SEARCH_FACET (SEARCH_FACET_ID, FIELD_ID, LABEL, SHOW_ON_SEARCH, MULTISELECT, SEARCH_DISPLAY_PRIORITY) VALUES (4, 8, 'Length', 0, 1, 0);
INSERT INTO BLC_CAT_SEARCH_FACET_XREF (CATEGORY_SEARCH_FACET_ID, CATEGORY_ID, SEARCH_FACET_ID, SEQUENCE) VALUES (4, 2003, 4, 4);

Where the CATEGORY_ID is the ID of the Category on which you want to apply this filter.

Hope this will be helpful to you.