It is not recommended to change the default files of OpenCart as if you upgrade then all changes will be lost so we have seen one solution to achieve your requirement by changing the header.tpl. Open catalog/view/theme/YOUR_THEME/template/common/header.tpl
Find the following lines of code:

<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>

And replace with following lines of code:

<ul class="list-unstyled">
  <?php foreach ($category['children'] as $key=>$child) { ?>
  <?php if($key<5){ ?>
  <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
  <?php } ?>
  <?php } ?>
</ul>

With this change, there will be only one column.

For many sub-categories, you can make multiple columns of sub-categories in OpenCart.
While inserting the category, in the data tab, insert the “Columns” value to show multiple columns. You can see examples of the “MP3 Players” category and its sub-categories in the default installation.

limit-sub-categories-opencart-menu


LEAVE A REPLY

Please enter your comment!
Please enter your name here