To add multiple categories and subcategories in Magento

To add multiple categories and subcategories in Magento

September 29, 2026 · Illustrated author avatarBy Stefan Bogdanescu
To add multiple categories and subcategories in Magento

Adding Multiple Categories and Subcategories in Magento: An Efficient Approach

If you’re looking to add multiple categories and subcategories in your Magento store simultaneously, you’ll appreciate this guide. Manually adding each category one by one isn’t practical when dealing with a large number of them. Let’s explore an efficient method to achieve this.

Understanding the Category Structure

In Magento, categories are organized hierarchically. You can have root (top-level) categories as well as subcategories and sub-subcategories. Each subcategory belongs directly under a parent category.

The category structure follows the following schema:

  • Root Category
    • Subcategory 1
      • Sub-subcategory 1a
        • Sub-sub-subcategory 1a1
    • Subcategory 2

Using the Magento API for Mass Category Creation

Magento provides an API that allows you to create, update, and delete categories programmatically. You can utilize this API to add your desired number of categories in one go.

Here’s a step-by-step guide:

Step 1: Create an API Key

Firstly, generate an API key with sufficient permissions. Navigate to System > Integrations > API Keys and click on the “Add New Key” button. Assign appropriate roles like ‘System’ or ‘Magento_Admin’.

Step 2: Prepare Your Data Structure

Your categories need to be structured appropriately for the API. They should follow a hierarchical JSON format.

{
    "category": [
        {
            "name": "Category 1",
            "parent_id": 0,
            "position": 1
        },
        {
            "name": "Subcategory 1 of Category 1",
            "parent_id": 1, // Parent ID is the category ID of 'Category 1'
            "position": 1
        }
    ]
}

Step 3: Use Magento’s REST API

You can now send a POST request to the following endpoint to create your categories:

https://<your-magento-instance>/rest/V1/categories

Include the JSON data you prepared in step 2 as the request body.

Adding Subcategories of Subcategories

To add sub-subcategories, simply nest them within their parent category’s JSON object. For example:

{
    "category": [
        {
            "name": "Category 1",
            "parent_id": 0,
            "position": 1
        },
        {
            "name": "Subcategory 1 of Category 1",
            "parent_id": 1, // Parent ID is the category ID of 'Category 1'
            "position": 1,
            "children": [
                {
                    "name": "Sub-subcategory 1 of Subcategory 1",
                    "parent_id": 2, // Parent ID is the subcategory's ID
                    "position": 1
                }
            ]
        }
    ]
}

Best Practices and Tips

  • Always test your API calls in a development environment before applying them to your live store.
  • Keep track of your category IDs for easy reference during updates or deletions.
  • Consider using third-party extensions like Amasty SEO Categories for advanced management features.

Conclusion

Adding multiple categories and subcategories in Magento doesn’t have to be a manual, time-consuming process. By leveraging the built-in REST API, you can efficiently create your category structure with just a few lines of JSON data and a HTTP POST request.

Remember that proper planning is essential before making any changes. Test your setup thoroughly to avoid potential issues during the deployment phase.

For more advanced Magento customizations, consider working with experienced developers like those at Laravel Company.

Happy coding!

Catalog Security API Admin

Our network