Troubleshooting: Catalog services do not retrieve products from specified catalog

When you use the CategoryDataBean to retrieve an entitled list of products, items, packages, and bundles that are in a category, the CategoryDataBean does not respect the catalogId that is passed from the API setCatalogId. Instead, the CategoryDataBean uses the catalogID that is set in the CatalogContext.

Problem

If your storefront catalog services include a set ID method to set a sales catalog ID for the CategoryDataBean and the services use WebSphere Commerce search to retrieve catalog objects, the services might not retrieve the catalog entries for the specified ID. For WebSphere Commerce search to use a specific sales catalog ID, the ID must be set within the _wcf.search.catalog control parameter or the catalog business context before the service is called. The services that use WebSphere Commerce search retrieve the catalog ID by using the following process:
  1. WebSphere Commerce search gets the catalog ID from the _wcf.search.catalog control parameter. This parameter is used to identify the catalog for the current search request and is a mandatory search and browsing context control parameter for each search request.
  2. If no ID is in the control parameter, WebSphere Commerce search gets the ID from the catalog context interface. For more information about this interface, see CatalogContext
  3. If the ID does not exist within the catalog context, WebSphere Commerce search uses the master catalog.

Solution

Publish a store that is based on the Aurora starter store and upgrade your store to use REST-based services. The WebSphere Commerce search architecture is based on the REST programming model. With this programming model, storefront services use getData tags to call WebSphere Commerce services that return BOD-structured data. RESTful APIs are used to call the WebSphere Commerce search server services that return simpler name-value formatted data. For more information about REST services, see
Alternatively, if you must continue to use your existing services, set the sales catalog ID within the catalog context before you call the service that needs the ID. For example,
  • If you need to call the CatalogNavigationView web service from a store page, you can set the sales catalog ID with code similar to the following code snippet.
    
    <wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType" var="catalogNavigationView" 
     expressionBuilder="getCatalogEntryViewPriceWithAttributesByID" varShowVerb="showCatalogNavigationView" recordSetStartNumber="0">
    <wcf:param name="UniqueID" value="${catEntryIdentifier}"/>
    <wcf:contextData name="storeId" data="${storeId}" />
    <wcf:contextData name="catalogId" data="${catalogId}" />
    </wcf:getData>
  • If you need to set the sales catalog ID manually before you call a data bean, you can use code similar to the following code snippet.
    
    ContextService cs = ContextServiceFactory.getContextService();
    CatalogContext catalogCtx = (CatalogContext) cs.findContext(CatalogContext.CONTEXT_NAME);
    if (catalogCtx != null) {
    String contextCatalogId = catalogCtx.getCatalogID();
    if (!catalogId.equals(contextCatalogId)) {
    catalogCtx.setCatalogID(catalogId);
    }
    }