Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
- ?>
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement