• Welcome to KonaKart Community Forum. Please login or sign up.
 

Problem with product options out of order

Started by paulh, September 05, 2007, 08:23:25 pm

Previous topic - Next topic

paulh


If u insert your product attributes and ur options are not contiguous ull end up with more selects that u bargain for - Im sure it will be fixed in the next release but heres a quick hack in the meantime - should be inserted before the product attributes are rendered in the productdetailsbody.jsp

<%
                  
                  ArrayList options = (ArrayList) selectedOpts;
                  Collections.sort(options, new Comparator() {
                  
                   public int compare(Object arg0, Object arg1) {
                      String  s1 = "" + ((ProdOptionContainer) arg0).getId();
                      String  s2 = "" + ((ProdOptionContainer) arg1).getId();
                      return s1.compareTo(s2);
                   }
                  });

                  ArrayList newOptions = new ArrayList(options);
                  
                  ProdOptionContainer current =  null;                  
                  for (int j=0; j < newOptions.size(); j++) {
                     
                     ProdOptionContainer prodOptionContainer =  (ProdOptionContainer) newOptions.get(j);
                     if (current!=null && current.getName().equals(prodOptionContainer.getName())) {
                        List values = prodOptionContainer.getOptValues();
                        for (int k=0; k < values.size(); k++) {
                           current.getOptValues().add(values.get(k));
                        }
                        options.remove(j);
                     } else {
                        current = prodOptionContainer;
                     }
                     
                  }
                                    
                  %>