VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Kuubs on October 12, 2020, 11:38:11 AM

Title: Get child categories by parent category id
Post by: Kuubs on October 12, 2020, 11:38:11 AM
Hello,

I'm trying to get the child categories by parent category id. Someoen know how to do this?
Title: Re: Get child categories by parent category id
Post by: Rsn on October 12, 2020, 12:26:23 PM
Try PHP class JFTree.
Look here http://forum.virtuemart.net/index.php?topic=137563.msg517279#msg517279
Just yesterday I wrote about it  :)
Title: Re: Get child categories by parent category id
Post by: Kuubs on October 12, 2020, 13:42:58 PM
Quote from: Rsn on October 12, 2020, 12:26:23 PM
Try PHP class JFTree.
Look here http://forum.virtuemart.net/index.php?topic=137563.msg517279#msg517279
Just yesterday I wrote about it  :)

I think there is also a method for this.. A native method implemented in the Virtuemart model.
Title: Re: Get child categories by parent category id
Post by: Kuubs on October 13, 2020, 15:16:53 PM
There should be some easy way right? How else is the category page getting the child categories as well? It's basically on the category page and I want to get the sub categories of a subcategory on the category page. So i have this category ID, so I should get the subcategories fairly easy right?

Found it:

$categoryModel= VmModel::getModel('category');
$categoryChildren = $categoryModelTemp->getChildCategoryList(0, $category->virtuemart_category_id);


Title: Re: Get child categories by parent category id
Post by: Rsn on October 13, 2020, 18:19:25 PM
@Huubs, it return children all levels?
Title: Re: Get child categories by parent category id
Post by: Kuubs on October 15, 2020, 09:53:22 AM
Quote from: Rsn on October 13, 2020, 18:19:25 PM
@Huubs, it return children all levels?
Only the subcategories from that category, which is what I wanted.