How to add Default Category to the Product index
Some site implementations need to add the Product's default Category to the SOLR index. The categories for products are managed in an associated table (blc_category_product_xref) and the default Category is marked as the "default_reference" in that xref table. The ability to identify and index the default Category can be confusing. Fortunately, we do have a helper method to allow us to get to the default Category. The ProductImpl#getCategory() method is implemented to find the default Category.
The ability to find the default Category through the getCategory method makes the addition of the default Category into the SOLR index much easier. Here are the steps needed:
1) Add the defaultCategory field to the blc_field table. This is a manual entry into the database.
INSERT INTO `blc_field` (`FIELD_ID`, `ABBREVIATION`, `CREATED_BY`, `DATE_CREATED`, `DATE_UPDATED`, `UPDATED_BY`, `ADMIN_ADDITION_STATUS`, `SITE_DISC`, `ENTITY_TYPE`, `FRIENDLY_NAME`, `OVERRIDE_GENERATED_PROP_NAME`, `PROPERTY_NAME`, `TRANSLATABLE`) VALUES (-1599, 'defCat', NULL, NULL, NULL, NULL, NULL, NULL, 'PRODUCT', 'Default Category', NULL, 'category.name', NULL);
INSERT INTO `blc_index_field` (`INDEX_FIELD_ID`, `ARCHIVED`, `CATALOG_DISC`, `SEARCHABLE`, `FIELD_ID`) VALUES (-1599, 'N', -1, 1, -1599); INSERT INTO `blc_index_field_type` (`INDEX_FIELD_TYPE_ID`, `ARCHIVED`, `CATALOG_DISC`, `FIELD_TYPE`, `INDEX_FIELD_ID`) VALUES (-1599, 'N', -1, 't', -1599);