I need to display all categories from one product on product view page.
This code I found, but it displays one category per line:
<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?>
< <a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?></a>
<?php endforeach; ?>
But I need it this way:
cat 1
cat 2 > subcat 1
cat 3 > subcat 1 > subcat 2