Scriptbaker
SCRIPTBAKERAI & Software Engineering
Magento

Get Magento root category id

[code language=”php”] public function getRootCategoryId() { $categories = Mage::getModel(‘catalog/category’)->getCollection()

· 5 min read

 public function getRootCategoryId() { $categories = Mage::getModel('catalog/category')->getCollection(); $categ_ids = $categories->getAllIds(); asort($categ_ids); foreach ($categ_ids as $k => $cat_id) { $category = Mage::getModel('catalog/category')->load($cat_id); if ($category->name) { return $cat_id; } } } 

S

Scriptbaker Editorial Team

The Scriptbaker editorial team comprises engineers, AI specialists, and digital strategists based in Dubai and Rawalpindi. We write about software development, artificial intelligence, and digital transformation to help organisations build better products. Learn more about us →