PHP – Magento – Get All Categories

The given PHP example returns the all categories in magento.

Code Example:
<?php
function getCategories() {
	$categories = Mage::getModel('catalog/category')
                    ->getCollection()
                    ->addAttributeToSelect('*')
                    ->addIsActiveFilter();
		
	$all = array();
	
	foreach ($categories as $c) {
	   $all[$c->getId()] = $c->getName();
	}
	
	return $all;
}
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

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