I just want to create a new category programmatically in purple. I have some code and tried this, but can't succeed.
The code is here: -
<?php
$parentId = '2';
$category = new Mage_Catalog_Model_Category();
$category->setName('check');
$category->setUrlKey('new-category');
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(0);
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$category->setPath($parentCategory->getPath());
$category->save();
unset($category);
?>
in fact, the problem with this code is whenever I tried it, than created a new category, but I canโt set is_active yes to admin.
source
share