Find All Leaf Categories - K8.2

Deb Apprille asked on May 11, 2017 17:01

My site directory consists of varying degrees of nested categories, such as:

  • Transportation > Personal Transpo > Car > Sedan (4 levels)
  • Transportation > Public Transpo > Bus (3 levels)

I am looking for a way to display a list of all leaf categories (i.e. Sedan and Bus), which don't have child categories.

I figured this would be a common request but have found nothing online. Does anyone have a solution?

Thanks,

Deb

Correct Answer

Peter Mogilnitski answered on May 11, 2017 19:07

You need to get all the leafs:)? Unfortunately there is not bit field in CMS_category table to tell if a category node has children or not. But you can easily achieve this with simple SQL query:

select p.* from CMS_Category p left outer join CMS_Category c on p.CategoryId = c.CategoryParentID
where c.Categoryid is null 

Give me all categories that don't have any children

0 votesVote for this answer Unmark Correct answer

Recent Answers


Deb Apprille answered on May 11, 2017 19:11

Oooo sneaky! That is a fantastic work-around! Thanks, Peter!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.