I am trying to get last level category name with its product count for each product on listing page. explained as below-
Category
-> Sub-category 1
->Sub-sub-category 11 -> Product 1
->Sub-sub-category 12
-> Sub-sub-sub-category 13 ->Product 2
-> Sub-category 2
->Sub-sub-category 21
-> Sub-sub-sub-category 22 ->Product 3
->Sub-sub-category 23 -> Product 4
I want to get only categories "Sub-sub-category 11", "Sub-sub-sub-category 13", "Sub-sub-sub-category 22" and "Sub-sub-category 23" which are the last level categories of Products 1, Products 2, Products 3, Products 4. I found below link https://stackoverflow.com/questions/20926118/get-last-level-category-name-of-a-product-in-magento but it only gets third level category.