Instead of display the Root category in menu, we need custom category in menu structure:
Copy the Mage/catalog/Model/Observer.php to local Mage/catalog/Model/Observer.php
Current Code:
1 2 3 4 5 6 7 8 9 |
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer) { $block = $observer->getEvent()->getBlock(); $block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG); $this->_addCategoriesToMenu( Mage::helper('catalog/category')->getStoreCategories(), $observer->getMenu(), $block, true ); } |
Replace Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
public function addCatalogToTopmenuItems(Varien_Event_Observer $observer) { $id=$this->getStoreCategories();//call the function of current file $block = $observer->getEvent()->getBlock(); $block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG); $this->_addCategoriesToMenu( $id, $observer->getMenu(), $block, true ); } public function getStoreCategories($sorted=false, $asCollection=false, $toLoad=true) { $parent = '45';//Define the custom Category Id; $cacheKey = sprintf('%d-%d-%d-%d', $parent, $sorted, $asCollection, $toLoad); if (isset($this->_storeCategories[$cacheKey])) { return $this->_storeCategories[$cacheKey]; } /** * Check if parent node of the store still exists */ $category = Mage::getModel('catalog/category'); /* @var $category Mage_Catalog_Model_Category */ if (!$category->checkId($parent)) { if ($asCollection) { return new Varien_Data_Collection(); } return array(); } $recursionLevel = max(0, (int) Mage::app()->getStore()->getConfig('catalog/navigation/max_depth')); $storeCategories = $category->getCategories($parent, $recursionLevel, $sorted, $asCollection, $toLoad); $this->_storeCategories[$cacheKey] = $storeCategories; return $storeCategories; } |