For anyone who wants answer for this I had to edit catalog/controller/common/header.php
and catalog/model/catalog/category.php
In category.php I added this function
public function getCategoryFirstChildId($category_id) {
$query = $this->db->query('SELECT category_id FROM '. DB_PREFIX .'category WHERE parent_id = '. (int)$category_id .' ORDER BY category_id ASC LIMIT 1');
return $query->row['category_id'];
}
and in header.php I made the code change as follows
/* New Code starts here */
/*NEW =>*/ $category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category['category_id']);
/*NEW =>*/ $first_child_id = $this->model_catalog_category->getCategoryFirstChildId($category['category_id']);
if($category_total>1)
{
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
else
{
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id']. '_' . $first_child_id)
);
}
/* New Code ends here */