Everyone knows there are admin interface to create categories, but if you want to create a category programmatically. Using Magento’s catalog/category model we can create a Magento category via a program. You have to set category title and Url key in order to show in the frontend.
Magento creates category programmatically
Here I’ve attached the PHP code for creating a category programmatically. You can write this in any controller or a PHP file that calls Magento’s bootstrapper. In the below example we are creating a category under a parent category 1
Note: You should have a parent category in order to create category,