Sunday 19 April 2015

how to get new root category of sub category in magento and display navigation in menu

how to get new root category of sub category in magento


$root_category = Mage::getModel('catalog/category')->load(7); // Put your root category ID here.

  $subcategories = $root_category->getChildren();?>

  

  <ul class="cat_list">
 
  <?php foreach(explode(',',$subcategories) as $subcategory) {

        $category = Mage::getModel('catalog/category')->load($subcategory);?>

echo $category->getName()?></a></li>

 <?php }?>

  </ul>

this will help you new root category get child cateogry check it

if you want to add new root category in your menu then 
just do and follow step

Go to Admin -> Catalog -> Manage Categories -> "Select Category" -> Display Settings -> Is Anchor = "Yes"

Then:

Admin -> System -> Index Management -> "Select All" -> "Reindex data" -> "Submit"

get defualt root category any where

Mage::app()->getStore("default")->getRootCategoryId()

any new root category then

Mage::app()->getStore($storeId)->getRootCategoryId();

No comments:

Post a Comment

Thank You For Comment