@RequestMapping(value = "/showProductList")
 public ModelAndView productlist(@RequestParam(value = "id") int id, HttpSession session) {
   ModelAndView mv = new ModelAndView("productList");
   mv.addObject("brandList", brandSrv.getById(id));
   Brand brand = brandSrv.getById(id);
   int foundProducts = 0;
   Set<Category> cats = brand.getCategory();
   Iterator<Category> itr = cats.iterator();
   while (itr.hasNext()) {
     Category cat = itr.next();
     foundProducts += cat.getProduct().size();
   }
   mv.addObject("foundSize", foundProducts);
   mv.addObject("isUserClickBrand", "true");
   mv.addObject("listOfBrands", brandSrv.getAllBrands());
   setLists(mv);
   if (session.getAttribute("cartSize") == null) {
     mv.addObject("cartSize", 0);
   } else {
     mv.addObject("cartSize", session.getAttribute("cartSize"));
   }
   return mv;
 }
  @RequestMapping(value = "/productListByFilterID")
  public ModelAndView productListByCatId(
      @RequestParam(value = "id") int id,
      @RequestParam(value = "bid") int bid,
      @RequestParam(value = "index") int index,
      HttpSession session) {
    ModelAndView mv = new ModelAndView("productList");
    mv.addObject("isUserClickByFilterID", "true");
    mv.addObject("listOfBrands", brandSrv.getAllBrands());
    if (session.getAttribute("cartSize") == null) {
      mv.addObject("cartSize", 0);
    } else {
      mv.addObject("cartSize", session.getAttribute("cartSize"));
    }

    int foundProducts = 0;
    if (index == 0) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", categorySrv.getById(id));
      try {
        Category category = categorySrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 1) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", productSizeSrv.getById(id));
      try {
        ProductSize category = productSizeSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 2) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameColorSrv.getById(id));
      try {
        FrameColor category = frameColorSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 3) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameMaterialSrv.getById(id));
      try {
        FrameMaterial category = frameMaterialSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 4) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameTypeSrv.getById(id));
      try {
        FrameType category = frameTypeSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 5) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", lensColorSrv.getById(id));
      try {
        LensColor category = lensColorSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 6) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", lensMaterialSrv.getById(id));
      try {
        LensMaterial category = lensMaterialSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {
      }
    }

    mv.addObject("brandList", brandSrv.getById(bid));
    mv.addObject("foundSize", foundProducts);
    setLists(mv);
    return mv;
  }