public abstract class AbstractNavigationSuggestion extends java.lang.Object implements NavigationSuggestion
This class provides helper methods for populating navigation suggestions.
This class will extend the interface 'NavigationSuggestion' and sets the
name-value pairs from the search configuration and implements
the method setProperties(Map properties)
.
The method getProperties()
should be called from within the handler extension class to access
the set of name-value pairs.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright notice field.
|
Constructor and Description |
---|
AbstractNavigationSuggestion() |
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.
|
abstract 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.
|
public static final java.lang.String COPYRIGHT
public 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'.
getProperties
in interface NavigationSuggestion
getProperties()
public 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'.
setProperties
in interface NavigationSuggestion
properties
- The set of customizable properties that were defined as name-value pairs in the search
configuration for a navigation suggestion handler.setProperties(Map)
public abstract 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);
populateSuggestion
in interface NavigationSuggestion
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
,
populateSuggestion(String, SuggestionViewType)