app/template/default/Product/list.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% extends 'default_frame.twig' %}
  9. {% set page_name = 'オンラインショップ' %}
  10. {% if Category is not empty %}
  11.     {% set page_name = Category.name %}
  12. {% endif %}
  13. {% block stylesheet %}
  14.     <style>
  15.         .cs-productList.container-1200 {
  16.             padding: 10px 20px 80px;
  17.             display: flex;
  18.             flex-wrap: wrap;
  19.             gap: 20px
  20.         }
  21.         .cs-productList .lib-eccube__item-product {
  22.             width: calc(25% - 15px);
  23.         }
  24.         @media screen and (max-width: 1279px) {
  25.             .cs-productList .lib-eccube__item-product {
  26.                 width: calc(33% - 13px);
  27.             }
  28.         }
  29.         @media screen and (max-width: 747px) {
  30.             .cs-productList .lib-eccube__item-product {
  31.                 width: calc(50% - 10px);
  32.             }
  33.         }
  34.         @media screen and (max-width: 420px) {
  35.             .cs-productList .lib-eccube__item-product {
  36.                 width: 100%;
  37.             }
  38.         }
  39.     </style>
  40. {% endblock %}
  41. {% block javascript %}
  42.     <script>
  43.         eccube.productsClassCategories = {
  44.             {% for Product in pagination %}
  45.             "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  46.             {% endfor %}
  47.         };
  48.         $(function() {
  49.             // 表示件数を変更
  50.             $('.disp-number').change(function() {
  51.                 var dispNumber = $(this).val();
  52.                 $('#disp_number').val(dispNumber);
  53.                 $('#pageno').val(1);
  54.                 $("#form1").submit();
  55.             });
  56.             // 並び順を変更
  57.             $('.order-by').change(function() {
  58.                 var orderBy = $(this).val();
  59.                 $('#orderby').val(orderBy);
  60.                 $('#pageno').val(1);
  61.                 $("#form1").submit();
  62.             });
  63.         });
  64.     </script>
  65. {% endblock %}
  66. {% block main %}
  67.     {% if search_form.category_id.vars.errors|length > 0 %}
  68.         <div class="ec-searchnavRole">
  69.             <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  70.         </div>
  71.     {% else %}
  72.         <div class="ec-searchnavRole">
  73.             <form name="form1" id="form1" method="get" action="?">
  74.                 {% for item in search_form %}
  75.                     <input type="hidden" id="{{ item.vars.id }}"
  76.                            name="{{ item.vars.full_name }}"
  77.                            {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  78.                 {% endfor %}
  79.             </form>
  80.             <div class="ec-searchnavRole__topicpath">
  81.                 <ol class="ec-topicpath">
  82.                     <li class="ec-topicpath__item"><a href="{{ url('product_list') }}">{{ '全て'|trans }}</a>
  83.                     </li>
  84.                     {% if Category is not null %}
  85.                         {% for Path in Category.path %}
  86.                             <li class="ec-topicpath__divider">|</li>
  87.                             <li class="ec-topicpath__item{% if loop.last %}--active{% endif %}"><a
  88.                                         href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a>
  89.                             </li>
  90.                         {% endfor %}
  91.                     {% endif %}
  92.                     {% if search_form.vars.value and search_form.vars.value.name %}
  93.                         <li class="ec-topicpath__divider">|</li>
  94.                         <li class="ec-topicpath__item">{{ '「%name%」の検索結果'|trans({ '%name%': search_form.vars.value.name }) }}</li>
  95.                     {% endif %}
  96.                 </ol>
  97.             </div>
  98.             <div class="ec-searchnavRole__infos">
  99.                 <div class="ec-searchnavRole__counter">
  100.                     {% if pagination.totalItemCount > 0 %}
  101.                         {{ '<span class="ec-font-bold">%count%件</span><span>の商品が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  102.                     {% else %}
  103.                         <span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span>
  104.                     {% endif %}
  105.                 </div>
  106.                 {% if pagination.totalItemCount > 0 %}
  107.                     <div class="ec-searchnavRole__actions">
  108.                         <div class="ec-select">
  109.                             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  110.                             {{ form_widget(search_form.orderby, {'id': '', 'attr': {'class': 'order-by'}}) }}
  111.                         </div>
  112.                     </div>
  113.                 {% endif %}
  114.             </div>
  115.         </div>
  116.         {% if pagination.totalItemCount > 0 %}
  117.             <div class="cs-productList container-1200">
  118.                 {% for Product in pagination %}
  119.                     <a href="{{ url('product_detail', {'id': Product.id}) }}" class="lib-eccube__item-product">
  120.                         <div class="img">
  121.                             <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  122.                         </div>
  123.                         <div class="text">
  124.                             <div class="categories">
  125.                                 {% set ProductCategory = ProductCategories[Product.id] %}
  126.                                 {% if ProductCategory is not empty %} <span>{{ ProductCategory.Category.name }}</span> {% endif %}
  127.                             </div>
  128.                             <p class="title">{{ Product.name }}</p>
  129.                         </div>
  130.                         <div class="util">
  131.                             <p class="price">
  132.                                 {% if Product.hasProductClass %}
  133.                                     {% if Product.getPrice02Min == Product.getPrice02Max %}
  134.                                         {{ Product.getPrice02IncTaxMin|price }}
  135.                                     {% else %}
  136.                                         {{ Product.getPrice02IncTaxMin|price }}~{{ Product.getPrice02IncTaxMax|price }}
  137.                                     {% endif %}
  138.                                 {% else %}
  139.                                     {{ Product.getPrice02IncTaxMin|price }}
  140.                                 {% endif %}
  141.                                 <span>(税込)</span>
  142.                             </p>
  143.                             <span class="link">詳細へ ></span>
  144.                         </div>
  145.                     </a>
  146.                 {% endfor %}
  147.             </div>
  148.             <div class="ec-pagerRole">
  149.                 {% include "pager.twig" with {'pages': pagination.paginationData} %}
  150.             </div>
  151.         {% endif %}
  152.     {% endif %}
  153. {% endblock %}