Переместите этот код:
{% if categories %}
{% if categories|length <= 5 %}
<div class="row">
<div class="col-sm-3">
<ul>
{% for category in categories %}
<li><a href="{{ category.href }}">{{ category.name }}</a></li>
{% endfor %}
</ul>
</div>
{% else %}
<div class="col-sm-3">{% for category in categories|batch((categories|length / 1)|round(1, 'ceil')) %}
<ul>
{% for child in category %}
<li><a href="{{ child.href }}">{{ child.name }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}</div>
<br />
{% endif %}
{% endif %}
Вставьте его перед строкой:
{% if not categories and not products %}
И не забудьте обновить кеш модификаторов и кеш twig, это можно сделать в админ части.