Writing it for my own help as my platform was configured in multi store views and by all means I was not getting the correct root category id. I all of the below solutions:
Sol 1:
Mage::app()->getStore($storeId)->getRootCategoryId(); //The result was ID: 2
Sol 2:
Mage::app()->getStore()->getRootCategoryId(); //The result was ID: 2
Sol 3:
$store = Mage::getModel('core/store')->load(Mage_Core_Model_App::DISTRO_STORE_ID);
$categoryId = $store->getRootCategoryId();// The result was again ID: 2
The method that only worked and returned ID: 1
is given below and was taken from here
public function getRootCategoryId()
{
$categories = Mage::getModel('catalog/category')->getCollection();
$categIds = $categories->getAllIds();
asort($categIds);
foreach ($categIds as $k => $catId)
{
$category = Mage::getModel('catalog/category')->load($catId);
if ($category->name)
{
return $catId;
}
}
}