use of org.broadleafcommerce.core.search.domain.SearchFacetDTO in project BroadleafCommerce by BroadleafCommerce.
the class DatabaseSearchServiceImpl method getCategoryFacets.
@Override
@SuppressWarnings("unchecked")
public List<SearchFacetDTO> getCategoryFacets(Category category) {
List<SearchFacetDTO> facets = null;
String cacheKey = CACHE_KEY_PREFIX + "category:" + category.getId();
Element element = cache.get(cacheKey);
if (element != null) {
facets = (List<SearchFacetDTO>) element.getValue();
}
if (facets == null) {
List<CategorySearchFacet> categorySearchFacets = category.getCumulativeSearchFacets();
List<SearchFacet> searchFacets = new ArrayList<SearchFacet>();
for (CategorySearchFacet categorySearchFacet : categorySearchFacets) {
searchFacets.add(categorySearchFacet.getSearchFacet());
}
facets = buildSearchFacetDtos(searchFacets);
element = new Element(cacheKey, facets);
cache.put(element);
}
return facets;
}
use of org.broadleafcommerce.core.search.domain.SearchFacetDTO in project BroadleafCommerce by BroadleafCommerce.
the class DatabaseSearchServiceImpl method findSearchResultsByCategory.
@Override
public SearchResult findSearchResultsByCategory(Category category, SearchCriteria searchCriteria) {
SearchResult result = new SearchResult();
setQualifiedKeys(searchCriteria);
List<Product> products = catalogService.findFilteredActiveProductsByCategory(category, searchCriteria);
List<SearchFacetDTO> facets = getCategoryFacets(category);
setActiveFacets(facets, searchCriteria);
result.setProducts(products);
result.setFacets(facets);
result.setTotalResults(products.size());
result.setPage(1);
result.setPageSize(products.size());
return result;
}
Aggregations