diff --git a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/CPSpecificationOptionFacetsDisplayContext.java b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/CPSpecificationOptionFacetsDisplayContext.java index adeb37de1b81d0..46f8051f7a38f1 100644 --- a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/CPSpecificationOptionFacetsDisplayContext.java +++ b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/CPSpecificationOptionFacetsDisplayContext.java @@ -61,6 +61,10 @@ public boolean hasCommerceChannel() throws PortalException { (CommerceContext)_httpServletRequest.getAttribute( CommerceWebKeys.COMMERCE_CONTEXT); + if (commerceContext == null) { + return false; + } + long commerceChannelId = commerceContext.getCommerceChannelId(); if (commerceChannelId > 0) { diff --git a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPOptionsSearchFacetDisplayContextBuilder.java b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPOptionsSearchFacetDisplayContextBuilder.java index f55e13d2986b51..75c6b367117f39 100644 --- a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPOptionsSearchFacetDisplayContextBuilder.java +++ b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPOptionsSearchFacetDisplayContextBuilder.java @@ -225,14 +225,18 @@ protected boolean isSelected(CPOption cpOption, String fieldValue) { } private List _getFacets() { - List filledFacets = new ArrayList<>(); - PortletSharedSearchResponse portletSharedSearchResponse = _portletSharedSearchRequest.search(_renderRequest); Facet facet = portletSharedSearchResponse.getFacet( CPField.OPTION_NAMES); + if (facet == null) { + return Collections.emptyList(); + } + + List filledFacets = new ArrayList<>(); + FacetCollector facetCollector = facet.getFacetCollector(); ThemeDisplay themeDisplay = portletSharedSearchResponse.getThemeDisplay( diff --git a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPSpecificationOptionsFacetDisplayContextBuilder.java b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPSpecificationOptionsFacetDisplayContextBuilder.java index c0f0641b39c0c9..02cddd5815c969 100644 --- a/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPSpecificationOptionsFacetDisplayContextBuilder.java +++ b/modules/apps/commerce/commerce-product-content-search-web/src/main/java/com/liferay/commerce/product/content/search/web/internal/display/context/builder/CPSpecificationOptionsFacetDisplayContextBuilder.java @@ -136,11 +136,15 @@ public void renderRequest(RenderRequest renderRequest) { _portletSharedSearchResponse = _portletSharedSearchRequest.search( _renderRequest); - List filledFacets = new ArrayList<>(); - Facet facet = _portletSharedSearchResponse.getFacet( CPField.SPECIFICATION_NAMES); + if (facet == null) { + return Collections.emptyList(); + } + + List filledFacets = new ArrayList<>(); + FacetCollector facetCollector = facet.getFacetCollector(); PortletPreferences portletPreferences =