app/template/default/Block/left_category.twig line 1

Open in your IDE?
  1. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  2. {% macro tree(Category) %}
  3.     {% from _self import tree %}
  4.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  5.         {{ Category.name }}
  6.     </a>
  7.     {% if Category.children|length > 0 %}
  8.         <ul>
  9.             {% for ChildCategory in Category.children %}
  10.                 <li>
  11.                     {{ tree(ChildCategory) }}
  12.                 </li>
  13.             {% endfor %}
  14.         </ul>
  15.     {% endif %}
  16. {% endmacro %}
  17. <div class="categories mt-4 p-3">
  18.     <h5 class="text-center fw-bold">CATEGORIES</h5>
  19.     <hr class="hr-custom">
  20.     <ul class="list-unstyled">
  21.         {% for category in Categories %}
  22.             {% set count = repository('Eccube\\Entity\\Product').countProductByCategory(category) %}
  23.             {% if count > 0 %}
  24.             <li class="mb-2"><i class="fa fa-angle-right mx-2" aria-hidden="true"></i><a href="{{ url('product_list', {'category_id': category.id}) }}">{{ category.name }}({{count}})</a></li>
  25.             {% endif %}
  26.         {% endfor %}
  27.     </ul>
  28. </div>