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

Category getLevel() always returns 0

Started by jvandevelde, July 20, 2011, 05:37:22 pm

Previous topic - Next topic

jvandevelde

Hi,

I'm having problems writing a category tree based on a set of search results. The problem I have is that calling categoryIf.getLevel() always returns 0.

For example, the following code:

Category catss[] = eng.getCategoryTree(-1, true);
for(Category c : catss)
{
   out.println("<br/>Level: " + c.getLevel());
   for(Category c2 : c.getChildren())
      out.println("<br/> Sub-Level: " + c.getLevel());
}

Returns

Level: 0
Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Sub-Level: 0
Level: 0

Is there something I have to do to get the level of a category to be populated?

Thanks,
Jules Van de Velde

jvandevelde

Sorry i saw where I went wrong with the last piece of code
the line out.println("<br/> Sub-Level: " + c.getLevel());
should be
out.println("<br/> Sub-Level: " + c2.getLevel());

I do still have the same problem when doing a search though

Product currProduct = prods[prod];   
Category[] prodCats = eng.getCategoriesPerProduct(currProduct.getId(), -1);

prodCats[0].getLevel() will always return 0 even though this is not correct