Out of Box, Autosuggest in the storefront searches for all products, across the entire master catalog & all the sales catalogs. If you are using esites, and have only a subset of the products from the master catalog in the sales catalog, this may not be the desired behaviour.
For example, a book store with different esites. They might have a 'technical manual' esite and a childrens book esite: technical manual esite searches don't want autosuggest suggestions of Harry Potter showing up. You can use the below customization to alter the default behaviour:
Note - this does not work for FEP7+ REST Searches. The autosuggest used in REST searches hardcodes the fields being searched. There is, however, an OOB sol'n for FEP7. For limiting keyword suggestions to a specific store/catalog, refer to the following KC page:
Solr Side Changes
1.1 Add a new schema field in the schema.xml for the CatalogEntry solr core:
<!--
Store related check field
-->
<dynamicField name="localSpellCheck_*" type="wc_textSpell" indexed="true" stored="false" multiValued="true" />
1.2.1 Add some new logic in the wc-data-config.xml for the CatalogEntry solr core:
In the header part add the following code (this transformer code will copy the product name, shortdescription and keyword into the related spellcheck field):
<script><![CDATA[
function copyToStoreSpellCheck(row) {
var nameStr = row.get('NAME');
var shtDescStr = row.get('SHORTDESCRIPTION');
var keywordStr = row.get('KEYWORD');
var catalogIdStr = row.get('catalog_id');
for (i=0;i<catalogIdStr.size();i++){
var catalogId = catalogIdStr.get(i);
var copyTo = new java.util.ArrayList();
copyTo.add(nameStr);
copyTo.add(shtDescStr);
copyTo.add(keywordStr);
row.put('localSpellCheck_'+catalogId, copyTo);
}
return row;
}
]]></script>
So the header of the file would look like:
1.2.2 inject all the transformers list with this newly created transformer. There will be 4 places in this file that need to be updated.
Here's an example of the change to make in the red box:
1.3 Redo full index build through di-preprocess and di-buildindex.
WC SIDE CHANGES
2.1 Find and change the invoker of autosuggest and add catalogId as a parameter.
In a toolkit environment, the jsp to change is:
WCDE_INT70\workspace\Stores\WebContent\AuroraStorefrontAssetStore\include\styles\style1\CachedHeaderDisplay.jsp
Add the new code
<c:param name="catalogId" value="${param.catalogId}" />
like in red box of the screen capture:
2.2 Find and change the spellCheck service invoker and add in the catalogId as part of the request:
Toolkit env the file to change is:
WCDE_INT70\workspace\Stores\WebContent\AuroraStorefrontAssetStore\Widgets\Search\AutoSuggestSerialize.jsp
The changes to make are as follows:
You'll then need to clear the temp dir/republish to see the jsp changes.