Limiting subcategories in the Prestashop Top Menu

In this quick tip we will see how to limit the number of subcategories the top menu displays in Prestashop.

Watch the Screencast

Text Version

Notice: if you are using a Prestashop version newer than, it’s recommended to apply this modification with an override, as explained here: How to override Prestashop modules

Open up modules/blocktopmenu/blocktopmenu.php

Locate the following method:

protected function generateCategoriesMenu($categories, $is_children = 0)

Inside it, you will notice a conditional block

if (isset($category[‘children’]) && !empty($category[‘children’]))
$html .= ‘<ul>’;
$html .= $this->generateCategoriesMenu($category[‘children’], 1);

if ((int)$category[‘level_depth’] > 1 && !$is_children)
$files = scandir(_PS_CAT_IMG_DIR_);

if (count($files) > 0)
$html .= ‘<li class="category-thumbnail">’;

foreach ($files as $file)
if (preg_match(‘/^’.$category[‘id_category’].’-([0-9])?_thumb.jpg/i’, $file) === 1)
$html .= ‘<div><img src="’.$this->context->link->getMediaLink(_THEME_CAT_DIR_.$file)
.’" alt="’.Tools::SafeOutput($category[‘name’]).’" title="’
.Tools::SafeOutput($category[‘name’]).’" class="imgm" /></div>’;

$html .= ‘</li>’;

$html .= ‘</ul>’;

We can do a number of things here. If we comment it out, all submenus will be removed. Otherwise, we can reduce and limit the subcategory levels:

if ($category[‘level_depth’] < 4 && isset($category[‘children’]) && !empty($category[‘children’]))


In this case, levels over 3 will not be displayed!

Need PrestaShop Modules? Have a look at my Prestashop Addons Store!

Looking for quality PrestaShop Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , | Posted under PrestaShop | RSS 2.0

Author Spotlight

Fabio Porta

Fabio has been involved in web development and design since 2005, when launched his first website at the age of 16. He’s now highly skilled in both client and server side development, along with design, and since August 2012 runs a successful website about PrestaShop tutorials and Prestashop Modules called Nemo’s Post Scriptum, at

Leave a Reply

Your email address will not be published. Required fields are marked *