I have created an 'ugly' solution but it works. Insert after line 23
$categoryIds = $this->params->get('category',0);
foreach ($categoryIds as $categoryId) {
if (JCategories::getInstance('content')->get($categoryId)->getChildren()){
foreach (JCategories::getInstance('content')->get($categoryId)->getChildren() as $childrencategory1)
{
if (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren()){
foreach (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren() as $childrencategory2)
{
if (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren()){
foreach (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren() as $childrencategory3)
{
if (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren()){
foreach (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren() as $childrencategory4)
{
if (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren()){
foreach (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren() as $childrencategory5)
{
if (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren()){
foreach (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren() as $childrencategory6)
{
if (JCategories::getInstance('content')->get($childrencategory6->id)->getChildren()){
}
else {
if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
}
}
}
else {
if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
}
}
}
else {
if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
}
}
}
else {
if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
}
}
}
else {
if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
}
}
}
else {
if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
}
}
}
}
foreach ($categoryIds as $categoryId) {
if (JCategories::getInstance('content')->get($categoryId)->getChildren()){
foreach (JCategories::getInstance('content')->get($categoryId)->getChildren() as $childrencategory1)
{
if (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren()){
if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
foreach (JCategories::getInstance('content')->get($childrencategory1->id)->getChildren() as $childrencategory2)
{
if (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren()){
if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
foreach (JCategories::getInstance('content')->get($childrencategory2->id)->getChildren() as $childrencategory3)
{
if (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren()){
if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
foreach (JCategories::getInstance('content')->get($childrencategory3->id)->getChildren() as $childrencategory4)
{
if (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren()){
if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
foreach (JCategories::getInstance('content')->get($childrencategory4->id)->getChildren() as $childrencategory5)
{
if (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren()){
if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
foreach (JCategories::getInstance('content')->get($childrencategory5->id)->getChildren() as $childrencategory6)
{
if (JCategories::getInstance('content')->get($childrencategory6->id)->getChildren()){
if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
}
else {
if (!in_array($childrencategory6->id, $categoryIds)){$categoryIds[] = $childrencategory6->id;}
}
}
}
else {
if (!in_array($childrencategory5->id, $categoryIds)){$categoryIds[] = $childrencategory5->id;}
}
}
}
else {
if (!in_array($childrencategory4->id, $categoryIds)){$categoryIds[] = $childrencategory4->id;}
}
}
}
else {
if (!in_array($childrencategory3->id, $categoryIds)){$categoryIds[] = $childrencategory3->id;}
}
}
}
else {
if (!in_array($childrencategory2->id, $categoryIds)){$categoryIds[] = $childrencategory2->id;}
}
}
}
else {
if (!in_array($childrencategory1->id, $categoryIds)){$categoryIds[] = $childrencategory1->id;}
}
}
}
}