Skip to content

Instantly share code, notes, and snippets.

@arioch1984
Last active August 29, 2015 14:10
Show Gist options
  • Save arioch1984/5522fea2efc6d451038e to your computer and use it in GitHub Desktop.
Save arioch1984/5522fea2efc6d451038e to your computer and use it in GitHub Desktop.
Programmatically create category
<?php
try{
$category = Mage::getModel('catalog/category');
$category->setName('check');
$category->setUrlKey('new-category');
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(1); //for active achor
$category->setStoreId(Mage::app()->getStore()->getId());
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$category->setPath($parentCategory->getPath());
$category->save();
} catch(Exception $e) {
var_dump($e);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment