Blog

WebSphere Commerce Search: Creating a Specific Price Range Facet Per Category

Usually, when you think of facets, you think about how they are related directly to the products. Generally, categories do not come into account. However, now with FEP5 on WebSphere Commerce 7, you can determine which facets display on a per category basis. Not only that, you can create different facets per category.

For example, perhaps you have a category with various price range facets at high dollar amounts. Then, you might have another category that has lesser dollar amount items that you want different price range facets from the first category. With FEP5, you can now do this. Although there is no UI built into Management Center (CMC), you can do this directly to the database with SQL inserts.

The following example changes price ranges for the sample Meat category in the Aurora store.

  1. Introduce a new Price searchable attribute
    insert into srchattr (srchattr_id, indexscope, indextype, identifier) values (1, ‘0’, ‘CatalogEntry’, ‘_cat:OfferPrice_USD_meats’);
  2. Define the ranges for it
    insert into srchattrprop (srchattr_id, propertyname, propertyvalue) values (1, ‘facet’, ‘price_USD:{* 7} 7;{7 11} 11;{11 15} 15;{15 *}’);
  3. Add facet config data in the new FEP5 facet tables
    insert into facet (facet_id, srchattr_id, selection, keyword_search, storeent_id, max_display) values (1, 1, 1, 0, 0, -1); insert into facetdesc (facet_id, language_id, name, description) values (1, -1, ‘Price for the Meat category (USD)’, ‘Price facet for the Meat category’);
  4. Disassociate the out of the box Price facet from the ‘Meat’ category
    insert into facetcatgrp (facetcatgrp_id, facet_id, sequence, storeent_id, catgroup_id, displayable) values (10001, -1002, 0.0, 10001, 10036, 0);
  5. Assign the new Price facet to the ‘Meat’ category
    insert into facetcatgrp (facetcatgrp_id, facet_id, sequence, storeent_id, catgroup_id, displayable) values (1, 1, 0.0, 10001, 10036, 1);
  6. Lastly, you’ll need to disassociate the new price facet to other categories
    insert into facetcatgrp (facetcatgrp_id, facet_id, sequence, storeent_id, catgroup_id, displayable) values (1, 1, 0.0, 10001, 0, 0);
    (The above insert is using catgroup_id=0 to represent the other categories)