magento create category programmatically

magento create category programmatically

In this post we’ll show you how to magento create category programmatically using magento. By using following code we can insert category programmatically and this code also work in exteranl magen to file.

Everybody knows there are administrator interface to make classes, yet in the event that you need to make a classification automatically. Utilizing Magento’s list/class show we can make a Magento classification by means of a program. You need to set class title and Url enter so as to show in the frontend.

Magento create category programmatically

Here we have connected the magento code for create category programmatically. You can compose this in any controller or a magento document that calls Magento’s bootstrapper. In the underneath illustration we are making a class under a parent classification 1

Note: You ought to have a parent classification keeping in mind the end goal to make classification

// code for create category programmatically
$parentId = '2'; // prenet catagory
$category = Mage::getModel('catalog/category');
$category->setName('category-name'); // category name
//$category->setUrlKey('your-category-url-key'); // url key
$category->setIsActive(1); // is active
$category->setIsAnchor(1); //for active anchor
$_parent_category = Mage::getModel('catalog/category')->load($parentId);
$cat_data= $category->save(); // insert catagory
//echo $cat_data->getEntityId();// print catagory id
catch(Exception $e)
print_r($e);//Exception in insert catagory

You also like Get Order Details using Order and customer registration programmatically and Magento2 admin login user detail and Magento 2 Featured products

Leave a Comment

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

66  +    =  75

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US