How to Display Magento Categories on Home Page or any Custom page?

Magento Show Categories on Homepage There are different ways to get Magento Categories on homepage or any custom page. Here we are going to discuss with them syntax or code to get the desired result.

Magento Display All Categories on Homepage (Active & Inactive)

The below code will fetch all categories (both active and inactive), which are present in your Magento Store.

$categories = Mage::getModel('catalog/category') -> getCollection() -> addAttributeToSelect('*');

Magento Get all active Categories

The below code will fetch all active categories from the record in your Magento Store thus filtering the inactive categories.

$categories = Mage::getModel('catalog/category')
Get active categories of any particular level

The below code will fetch all active categories of particular level. Here, We have selected level 2.

$categories = Mage::getModel('catalog/category')->getCollection()

You can also display useful information like Name, URL, id etc. by following code:

foreach ($categories as $category)
$entity_id = $category->getId();
$name = $category->getName();
$url_key = $category->getUrlKey();
$url_path = $category->getUrl();

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *