Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. $parentId = '2';
  3.  
  4. $category = new Mage_Catalog_Model_Category();
  5. $category->setName('check');
  6. $category->setUrlKey('new-category');
  7. $category->setIsActive(1);
  8. $category->setDisplayMode('PRODUCTS');
  9. $category->setIsAnchor(0);
  10.  
  11. $parentCategory = Mage::getModel('catalog/category')->load($parentId);
  12. $category->setPath($parentCategory->getPath());
  13.  
  14. $category->save();
  15. unset($category);
  16.  
  17. ?>
  18.  
  19. try{
  20. $category = Mage::getModel('catalog/category');
  21. $category->setName('check');
  22. $category->setUrlKey('new-category');
  23. $category->setIsActive(1);
  24. $category->setDisplayMode('PRODUCTS');
  25. $category->setIsAnchor(1); //for active achor
  26. $category->setStoreId(Mage::app()->getStore()->getId());
  27. $parentCategory = Mage::getModel('catalog/category')->load($parentId);
  28. $category->setPath($parentCategory->getPath());
  29. $category->save();
  30. } catch(Exception $e) {
  31. var_dump($e);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement