How to show All (product) Categories List in admin side: Magento

How to show All (product) Categories List in admin side: Magento

September 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to show All (product) Categories List in admin side: Magento

Showing All Product Categories in Magento Admin

As an experienced developer working on e-commerce platforms like Magento, I frequently encounter questions about displaying various data elements in the admin interface. One common request is to show all product categories as a multiselect option in the system configuration. Let’s dive into a practical solution for this requirement.

Understanding the Current Approach

The provided code snippet attempts to load and display category information using Magento’s built-in category model and collection. The intent is clear: to iterate through available categories and output their names. However, there are two key issues with this approach:

  1. It loads all categories, including those that may not be relevant to the product catalog (e.g., non-product ones).

  2. The current condition $_category->getIsActive() will only show active categories. While this is a good start, it doesn’t ensure we’re working with product-related categories specifically.

A More Targeted Solution

To achieve our goal of showing only product categories in the admin interface as a multiselect option, we need to apply a more restrictive filter. Here’s an improved approach:

$_category = Mage::getModel('catalog/category');
$collection = $_category->getCollection()->addFieldToFilter('entity_type_id', 3); // Entity type ID for product categories

foreach ($collection as $cat) {
    if ($cat->getIsActive()) {
        echo $this->helper('core')->escapeHtml($cat->getName());
    }
}

In this code:

  • We use the getCollection() method directly on the category model to obtain a collection of all categories.
  • The addFieldToFilter method is used to restrict the collection to only those with an entity type ID of 3, which corresponds to product categories in Magento.
  • We still check if the category is active using $cat->getIsActive(), ensuring we don’t show inactive ones.

Incorporating Multiselect Option

To display these categories as a multiselect option in your system configuration XML file, you can use the following structure:

<multiselect id="your_configuration_field_id">
    <label>Product Categories</label>
    <source_model>catalog/category_source_product</source_model>
</multiselect>

Here’s what this does:

  • id: Replace with your own unique field ID.
  • label: The label that will appear in the admin interface for this field.
  • source_model: Specifies the source model used to populate the dropdown options. In our case, we use the built-in Magento category source model for products.

Remember to replace your_configuration_field_id with your actual configuration field ID when implementing this in your module’s system.xml file.

Conclusion and Further Reading

Displaying product categories as a multiselect option in the admin interface is a common requirement that can be achieved using Magento’s built-in models and collections. By applying the appropriate filters, we can ensure our solution only shows relevant, active product categories.

For more information on working with Magento configurations and system.xml files, I recommend checking out our guide to creating custom configuration fields on LaravelCompany. It provides a step-by-step walkthrough of the process.

Additionally, understanding how to work with collections in Magento is a crucial skill for any developer. If you’re looking to dive deeper into this topic, our article on Magento 2 collections offers an excellent starting point.

Happy coding!

Catalog API Admin Configuration

Our network