In Magento how do I get the listing of categories in the order you see in the admin area?

In Magento how do I get the listing of categories in the order you see in the admin area?

July 25, 2026 · Illustrated author avatarBy Stefan Bogdanescu
In Magento how do I get the listing of categories in the order you see in the admin area?

Ordering Categories in Magento as Per Admin Area

As a senior developer experienced in e-commerce platforms like Magento, I understand your challenge of displaying categories in the same order you see them in the admin area. The built-in functions don’t directly provide this capability, but we can achieve it with some custom code.

The issue lies in the way Magento manages category hierarchy and sorting. By default, when you call getChildren() on a category, you get an unsorted array of child category IDs. This is why your current implementation doesn’t match the admin area’s ordering.

To solve this, we need to leverage Magento’s built-in sorting capabilities for categories. When you create or manage categories in the admin panel, Magento updates the catalog_category_entity_int table with a position field that represents the category’s order within its parent.

Here’s how we can retrieve categories in their admin-ordered sequence:

public function getOrderedCategories($parentCategoryId)
{
    $collection = Mage::getResourceModel('catalog/category_collection')
        ->addFieldToFilter('parent_id', $parentCategoryId)
        ->setOrder('position', Varien_Data_Collection_Db::SORT_ORDER_ASC);

    return $collection;
}

In this function, we create a new category collection and filter it by the parent category ID. The important part is the setOrder method, which sorts the collection by the position field in ascending order (Varien_Data_Collection_Db::SORT_ORDER_ASC).

You can then loop through this collection to display your categories:

$categories = $this->getOrderedCategories($categoryId);
foreach ($categories as $category) {
    echo '<a href="'.$category->getUrl().'">'.$category->getName().'</a><br>';
}

This code will give you the list of child categories for a specific parent category, sorted exactly as they appear in the admin area.

Remember to replace $categoryId with the actual ID of the parent category you want to retrieve children from. You can find this ID in the URL when editing a category in the Magento backend (e.g., catalog/adminhtml_category/edit/category_id/123).

If you need more advanced functionality or specific styling, consider using Magento’s theme system and custom layout files. For a comprehensive guide on Magento development, I recommend checking out the Laravel Company for professional services and resources.

The key takeaway is that while Magento provides robust category management features, you sometimes need to dig into its model architecture to achieve specific display orders. By leveraging the position field in the category collection, we can maintain consistency between our frontend displays and the admin area sorting.

Catalog Database Admin Orders

Our network