sudhakar phad
sudhakar phad

Reputation: 191

How to get all categories and subcategories name in Virtuemart

i created a HTML module and loaded in virtuemart category layout but i need to show all category and subcategory name list so that when user added new category in future , it will updated automatically . no need to hardcode every time. please help on this topic. you can load these categories name by using while loops in PHP. please reply fast.

Upvotes: 1

Views: 2860

Answers (2)

Anant
Anant

Reputation: 534

As VirtueMart don't provide this hierarchical structure at front-end you have to build your own method. Though at back-end you can use @Jobin's answer. I have implement and tested it for the front-end, it works with ease. Check the answer here

https://webkul.com/blog/get-parent-child-categories-hierarchical-tree-joomla-virtuemart/

Upvotes: 1

Jobin
Jobin

Reputation: 8282

Try this,

If you are doing with module then in your module file(mod_yourmodule.php) add the following codes.

if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
$categoryModel = VmModel::getModel('Category');
$cats = $categoryModel->getCategoryTree();//Params $parentId=0, $level = 0, $onlyPublished = true,$keyword = ''
echo "<pre/>";
print_r($cats);

Hope its helps..

Upvotes: 5

Related Questions