It is not recommended to change the default files of OpenCart as if you upgrade then all changes will be lost.
I have seen one solution to achieve your requirement by changing the header.tpl. Open catalog/view/theme/YOUR_THEME/template/common/header.tpl
Find 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 column of sub-categories in OpenCart.
While inserting category, in the data tab, insert “Columns” value to show multiple columns. You can see examples of “MP3 Players” category and its sub-categories in default installation.

limit-sub-categories-opencart-menu

LEAVE A REPLY

Please enter your comment!
Please enter your name here