public static String addCategoryDefaults(HttpServletRequest request,HttpServletResponse response){
  String itemGroupNumber=request.getParameter("itemGroupNumber");
  String categoryId=request.getParameter("category_id");
  String catalogId=CatalogWorker.getCurrentCatalogId(request);
  ShoppingCart cart=getCartObject(request);
  Delegator delegator=(Delegator)request.getAttribute("delegator");
  LocalDispatcher dispatcher=(LocalDispatcher)request.getAttribute("dispatcher");
  ShoppingCartHelper cartHelper=new ShoppingCartHelper(delegator,dispatcher,cart);
  String controlDirective;
  Map<String,Object> result;
  BigDecimal totalQuantity;
  Locale locale=UtilHttp.getLocale(request);
  result=cartHelper.addCategoryDefaults(catalogId,categoryId,itemGroupNumber);
  controlDirective=processResult(result,request);
  if (controlDirective.equals(ERROR)) {
    return "error";
  }
 else {
    totalQuantity=(BigDecimal)result.get("totalQuantity");
    Map<String,Object> messageMap=UtilMisc.<String,Object>toMap("totalQuantity",UtilFormatOut.formatQuantity(totalQuantity.doubleValue()));
    request.setAttribute("_EVENT_MESSAGE_",UtilProperties.getMessage(resource_error,"cart.add_category_defaults",messageMap,locale));
    return "success";
  }
}

public static String addCategoryDefaults ( HttpServletRequest request , HttpServletResponse response ) { String itemGroupNumber = request . getParameter ( "itemGroupNumber" ) ; String categoryId = request . getParameter ( "category_id" ) ; String catalogId = CatalogWorker . getCurrentCatalogId ( request ) ; ShoppingCart cart = getCartObject ( request ) ; Delegator delegator = ( Delegator ) request . getAttribute ( "delegator" ) ; LocalDispatcher dispatcher = ( LocalDispatcher ) request . getAttribute ( "dispatcher" ) ; ShoppingCartHelper cartHelper = new ShoppingCartHelper ( delegator , dispatcher , cart ) ; String controlDirective ; Map < String , Object > result ; BigDecimal totalQuantity ; Locale locale = UtilHttp . getLocale ( request ) ; result = cartHelper . addCategoryDefaults ( catalogId , categoryId , itemGroupNumber ) ; controlDirective = processResult ( result , request ) ; if ( controlDirective . equals ( ERROR ) ) { return "error" ; } else { totalQuantity = ( BigDecimal ) result . get ( "totalQuantity" ) ; Map < String , Object > messageMap = UtilMisc . < String , Object > toMap ( "totalQuantity" , UtilFormatOut . formatQuantity ( totalQuantity . doubleValue ( ) ) ) ; request . setAttribute ( "_EVENT_MESSAGE_" , UtilProperties . getMessage ( resource_error , "cart.add_category_defaults" , messageMap , locale ) ) ; return "success" ; } }
adds all products in a category according to default quantity on productcategorymember for each ; if no default for a certain product in the category , or if quantity is 0 , do not add
