Extend the WebSphere Commerce search configuration file (wc-search.xml) to support the warranty type suggestion group
In this lesson,
you extend the wc-search.xml file to return warranty
type data to the cached auto-suggest menu. The extension includes
registering the Java class that you created in the previous lesson,
and extending two existing search profiles.To
review information about the wc-search.xml file
and search profiles, see WebSphere Commerce search configuration file (wc-search.xml) (WC EAR).
About this task
Then,
you must extend two existing search profiles:
IBM_findNavigationSuggestions
search profileIBM_findCatalogEntryByNameAndShortDescription
search profile
Procedure
- Add a search profile to add a suggestion group for warranty
terms:
- Open your custom wc-search.xml file
in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
Note: You created this custom file in the prerequisite tutorials.
- Locate the following line of code:
</_config:search-config>
- Above the
</_config:search-config>
element, insert the following lines of code:<_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions"> <_config:navigationSuggestion> <_config:suggestion handler="com.mycompany.commerce.search.WarrantySuggestion" name="myID" /> </_config:navigationSuggestion> </_config:profile>
- Save the file but do not close it.
- Open your custom wc-search.xml file
in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
- Copy the navigation suggestions definition from the default
wc-search.xml
file into your custom file:- Go to the WC/xml/config/com.ibm.commerce.catalog-fep directory.
- Open the default WebSphere Commerce search configuration file, wc-search.xml.
- Find the definition of the
IBM_findNavigationSuggestions
profile, as shown here:<_config:profile indexName = "CatalogEntry" name = "IBM_findNavigationSuggestions"> <_config:query> <_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> A <_config:suggestion name = "Category" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.CategoryNavigationSuggestion"/> <_config:suggestion name = "Brand" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.BrandNavigationSuggestion"/> <_config:suggestion name = "Articles" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.WebContentNavigationSuggestion"> <_config:param name = "totalNumber" value = "100"/> </_config:suggestion> B </_config:navigationSuggestion> </_config:profile>
- Copy the XML node that begins with A and
ends with B into your custom wc-search.xml file.
In the file, copy the node to the location shown here:
<_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions"> <_config:navigationSuggestion> <_config:suggestion handler="com.mycompany.commerce.search.WarrantySuggestion" name="myID" /> **********************COPY HERE************************** </_config:navigationSuggestion> </_config:profile>
- Save the file but do not close it.
- Create a search profile to fetch all warranty type information
through a search request:
- In your custom
wc-search.xml
file, locate the following line of code:</_config:search-config>
- Above the
</_config:search-config>
element, insert the following new profile:<_config:profile extends = "IBM_extensionProfile" name = "x_MyCompany_findNavigationSuggestion_Warranty"> <_config:query inherits = "false"> <_config:param name = "debug" value = "false"/> <_config:param name = "maxRows" value = "100"/> <_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.SolrSearchByStorePathExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByCategoryExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchFacetConditionExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByPublishedEntryOnlyExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchTypeExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProductEntitlementExpressionProvider"/> <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/> </_config:query> <_config:facets inherits = "false"> <_config:param name = "sort" value = "index"/> <_config:param name = "minCount" value = "1"/> <_config:param name = "limit" value = "100"/> <_config:category scope = "all"> <_config:facet name = "*"/> </_config:category> </_config:facets> </_config:profile>
- Save the file but do not close it.
- In your custom
- Create a search profile to search against the warranty
information and return the catalog entries that match the warranty
type that the customer searched for:Note: The search profile findCatalogEntryByWarranty was already added in the prerequisite tutorial,Adding the new search profile
- Open your custom wc-search.xml file in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
- Locate the following line of code:
<_config:profile name="X_findCatalogEntryByWarranty" extends="IBM_findCatalogEntryByNameAndShortDescription"> <_config:query inherits="true">
- Change the line
<_config:query inherits="true">
from true to false - Insert the following code right after the line
<_config:query inherits="false">
:<_config:param name="debug" value="false"/> <_config:param name="maxRows" value="100"/> <_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.SolrSearchByKeywordExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByStorePathExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByCategoryExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByPublishedEntryOnlyExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchTypeExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProductEntitlementExpressionProvider"/> <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/> <_config:field name="wartype" /> </_config:query> </_config:profile>
- Save and close the file.
Results
wc-search.xml
file
with the changes in this lesson.