Search in sources :

Example 1 with ProductCategory

use of com.nixmash.blog.mvc.containers.ProductCategory in project nixmash-blog by mintster.

the class SolrController method productCategories.

@RequestMapping(value = "/products/categories", method = RequestMethod.GET)
public String productCategories(Model model) {
    FacetPage<Product> catfacetPage = productService.getFacetedProductsCategory();
    Page<FacetFieldEntry> catPage = catfacetPage.getFacetResultPage(Product.CATEGORY_FIELD);
    List<ProductCategory> results = new ArrayList<ProductCategory>();
    for (FacetFieldEntry entry : catPage) {
        results.add(new ProductCategory(entry.getValue(), toIntExact(entry.getValueCount())));
    }
    model.addAttribute(MODEL_ATTRIBUTE_PRODUCT_CATEGORIES, results);
    return PRODUCT_CATEGORIES_VIEW;
}
Also used : FacetFieldEntry(org.springframework.data.solr.core.query.result.FacetFieldEntry) ProductCategory(com.nixmash.blog.mvc.containers.ProductCategory) Product(com.nixmash.blog.solr.model.Product)

Aggregations

ProductCategory (com.nixmash.blog.mvc.containers.ProductCategory)1 Product (com.nixmash.blog.solr.model.Product)1 FacetFieldEntry (org.springframework.data.solr.core.query.result.FacetFieldEntry)1