public interface NavigationSuggestion
All Navigation suggestions implement this interface. Navigation suggestions are automatically displayed when shoppers type search terms
in the search box on the store front. Suggestions are also grouped into categories.
For example:
Classes should extend com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.AbstractNavigationSuggestion
and implement this interface.
The search framework calls the com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter
which calls the populateSuggestion method of each NavigationSuggestion defined in the wc-search.xml file.
Each implementation class has access to custom properties that can be defined through configuration in the wc-search.xml file. They
can be accessed via the getProperties()
method. The superclass AbstractNavigationSuggestion
sets the properties
read from the configuration file into the map. See the description of 'profile -> navigationSuggestion -> param' in the wc-search.xml below for
an example.
The list of navigation suggestions are configured in the wc-search.xml file. The search profile named IBM_findNavigationSuggestions is invoked by
the store front to get the suggestions. If you wish to add additional NavigationSuggestions, extend this search profile.
IBM Internal:
Each one of these implementations must be configured under this search profile, IBM_findNavigationSuggestions, for it to be invoked.
(com.ibm.commerce.catalog-fep/wc-search.xml)
Customers:
Customers must extend this search profile to add their own suggestion handlers. All of the content should be copied from the profile 'IBM_findNavigationSuggestions'
and placed in their extension profile (com.ibm.commerce.catalog-ext/wc-search.xml)
wc-search.xml
snippet:
<_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions">
<_config:query>
<_config:param name="debug" value="false"/>
<_config:param name="maxRows" value="50"/>
<_config:param name="maxTimeAllowed" value="5000"/>
<_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProfileNameValidator"/>
<_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchIndexNameValidator"/>
<_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchNoSearchResultsExpressionProvider"/>
<_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/>
</_config:query>
<_config:result>
<_config:filter classname="com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter"/>
</_config:result>
<_config:navigationSuggestion>
<_config:suggestion name="Brand"
handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.BrandNavigationSuggestion">
</_config:suggestion>
<_config:suggestion name="Category"
handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.CategoryNavigationSuggestion">
</_config:suggestion>
<_config:suggestion name="Articles"
handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.WebContentNavigationSuggestion">
<_config:param name="totalNumber" value="100"/>
</_config:suggestion>
<_config:suggestion name="MyCustomNavigationSuggestion"
handler="com.mycompany.search.suggestion.solr.MyNavigationSuggestion">
<_config:param name="myCustomProperty" value="1000"/>
</_config:suggestion>
</_config:navigationSuggestion>
</_config:profile>
In the search profile, the following information is required:
populateSuggestion(...)
method for each handler to populate their suggestion.
In the search profile, the following information is optional:
com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter
will instantiate a suggestionView for you, set the identifier, if the name attribute is defined in the wc-search.xml configuration and
will pass it to populateSuggestion method of your NavigationSuggestion.
ie. suggestionView.setIdentifier(handlerName);
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright notice field.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map |
getProperties()
This method returns the set of customizable properties that were defined as name-value pairs in the search
configuration for a navigation suggestion handler.
|
void |
populateSuggestion(java.lang.String profile,
com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType suggestionCategory)
This method populates a single navigation suggestion category for use in the storefront.
|
void |
setProperties(java.util.Map properties)
This method sets the list of customizable properties that were defined as name-value pairs in the search
configuration for a navigation suggestion handler.
|
static final java.lang.String COPYRIGHT
void populateSuggestion(java.lang.String profile, com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType suggestionCategory)
This method populates a single navigation suggestion category for use in the storefront.
This method should return all possible values for this navigation suggestion category. (ie. All brands, categories, articles that will be used to aid navigation in the store)
The object suggestionCategory
must be populated with your suggestion category information
for your navigation suggestion to be displayed on the storefront.
In the storefront, the service is called to return all possible values for each navigation suggestion category. The storefront performs the filtering of the values as the customer types into the quick search box.
Modifications to the storefront JSPs are required. See the information center for more information describing the storefront JSPs modifications.
The JSPs requiring modification are:
This method will need to fetch all values for this NavigationSugesstion category from a data source (typically the database or the search engine)
and mediate this data into the suggestionCategory (com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType
) and its
corresponding entries, (com.ibm.commerce.catalog.facade.datatypes.SuggestionEntryViewType
).
The following is a description of the SuggestionViewType and SuggestionEntryViewType objects that must be populated:
The xml data structure looks like this:
<_cat:SuggestionView>
<_cat:Identifier>Brand</_cat:Identifier>
<_cat:Label>Brand</_cat:Label>
<_cat:Entry>
<_cat:Name>MapleWear</_cat:Name>
<_cat:Value>mfName_ntk_cs</_cat:Value>
<_cat:Image>MapleWear</_cat:Image>
<_cat:UserData>
<_wcf:UserDataField name="Count">418</_wcf:UserDataField>
</_cat:UserData>
</_cat:Entry>
<_cat:Entry>
<_cat:Name>Sharpson</_cat:Name>
<_cat:Value>mfName_ntk_cs</_cat:Value>
<_cat:Image>Sharpson</_cat:Image>
<_cat:UserData>
<_wcf:UserDataField name="Count">20</_wcf:UserDataField>
</_cat:UserData>
</_cat:Entry>
</_cat:SuggestionView>
ie. Integer iLangId = CatalogComponentHelper.getLanguageId();
ie. Integer iLangId = CatalogComponentHelper.getLanguageId();
The following is an example of how to create navigation suggestion entries (SuggestionEntryViewType
)
and populate them.
// Get the list of suggestion entries ListsuggestionEntries = suggestionCategory.getEntry(); ... // Set the label suggestionCategory.setLabel(label); ... // Create and populate the entries SuggestionEntryViewType suggestionEntry = CatalogFactory.eINSTANCE.createSuggestionEntryViewType(); com.ibm.commerce.foundation.common.datatypes.UserDataType userData = suggestionEntry.getUserData(); if(userData==null) { userData = CommerceFoundationFactory.eINSTANCE.createUserDataType(); } suggestionEntry.setUserData(userData); // Populate suggestion entry // Name suggestionEntry.setName("My suggestion name"); // Value suggestionEntry.setValue("My suggestion value to help the store developer build a URL for when a customer clicks on my suggestion"); // Image suggestionEntry.setImage("My suggestion image"); // User data Map userDataFields = userData.getUserDataField(); userDataFields.put("myCustomProperty", "myCustomValue"); // Finally, add this entry to the list of entries suggestionEntries.add(suggestionEntry);
profile
- The search profile name.suggestionCategory
- An instantiated SuggestionViewType
object. You must populate this object with your suggestions.
If this navigation suggestion handler was configured with a name, the identifier is pre-populated in the SuggestionViewType
object.SuggestionViewType
,
SuggestionEntryViewType
,
AbstractNavigationSuggestion.populateSuggestion(String, SuggestionViewType)
java.util.Map getProperties()
This method returns the set of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
ie. <_config:param name="myCustomProperty" value="1000"/> The key in the properties map is 'myCustomProperty' and the value is '1000'.
AbstractNavigationSuggestion.getProperties()
void setProperties(java.util.Map properties)
This method sets the list of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
ie. <_config:param name="myCustomProperty" value="1000"/> The key in the properties map is 'myCustomProperty' and the value is '1000'.
properties
- The set of customizable properties that were defined as name-value pairs in the search
configuration for a navigation suggestion handler.AbstractNavigationSuggestion.setProperties(Map)