app/template/airconwork/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 body_class = 'product_page' %}
  10. {% block javascript %}
  11. <script>
  12. // 検索後パラメータをフォームにセット
  13.     function getParam(name, url) {
  14.         if (!url) url = window.location.href;
  15.         name = name.replace(/[\[\]]/g, "\\$&");
  16.         var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
  17.             results = regex.exec(url);
  18.         if (!results) return null;
  19.         if (!results[2]) return '';
  20.         return decodeURIComponent(results[2].replace(/\+/g, " "));
  21.     }
  22.     //商品名 or 型番入力検索
  23.     $("input[name='name']").val(getParam('name'));
  24.     //電源
  25.     var tag = getParam('tag');
  26.     if (tag) {
  27.     var tagId='tag_id_' + tag ;
  28.         var sel = document.querySelector('[data-id="' + tagId + '"]');
  29.         sel.selected = true;
  30.     }
  31.     var urlParams = new URLSearchParams(window.location.search);
  32.     var categoryIds = urlParams.getAll('category_ids[]');
  33.     //カテゴリ
  34.     for (i = 0; i < categoryIds.length; i++) {
  35.         if (categoryIds[i]!="") {
  36.             var cat='category_id_' + categoryIds[i] ;
  37.             var sel = document.querySelector('[data-id="' + cat + '"]');
  38.             var type = sel.getAttribute("type");
  39.             if (type=="radio") {
  40.                 sel.checked= true;;
  41.             }else{
  42.                 sel.selected = true;
  43.             }
  44.         }
  45.     }
  46.     /*eccube.productsClassCategories = {
  47.         {% for Product in pagination %}
  48.         "{{ Product.id|escape('js') }}": {{ class_categories_as_json(Product)|raw }}{% if loop.last == false %}, {% endif %}
  49.         {% endfor %}
  50.     };*/
  51.     $(function() {
  52.         // 表示件数を変更
  53.         $('.disp-number').change(function() {
  54.             var dispNumber = $(this).val();
  55.             $('#disp_number').val(dispNumber);
  56.             $('#pageno').val(1);
  57.             $("#form1").submit();
  58.         });
  59.         // 並び順を変更
  60.         $('.order-by').change(function() {
  61.             var orderBy = $(this).val();
  62.             $('#orderby').val(orderBy);
  63.             $('#pageno').val(1);
  64.             $("#form1").submit();
  65.         });
  66.     });
  67. </script>
  68. {% endblock %}
  69. {% set catIds = app.request.get('category_ids') %}
  70. {% set cid = "" %}
  71. {% set cnt = 0 %}
  72. {% for catId in catIds %}
  73. {% if catId !="" %}
  74. {% set cnt = cnt + 1 %}
  75. {% set cid = catId %}
  76. {% endif %}
  77. {% endfor %}
  78. {% if cnt == 1 %}
  79. {% set Category = repository('Eccube\\Entity\\Category').find(cid) %}
  80. {% endif %}
  81. {% block title %}
  82. <h1 class="c-title-06">
  83. <span class="s-text">
  84. {% if cnt == 1 %}
  85. {{ Category.name }}のエアコン商品一覧{# カテゴリーページ #}
  86. {% else %}
  87. エアコン商品一覧
  88. {% endif %}
  89. </span>
  90. </h1>
  91. {% endblock %}
  92. {% block main_head %}
  93. {% if cnt == 1 %}
  94. <div class="c-section">
  95.     <div class="c-media-01">
  96.         {% if Category.category_image %}
  97.         <figure class="s-image">
  98.         <div class="s-image__in">
  99.         <img src="{{ asset(Category.category_image|no_image_product, 'save_image') }}" alt="{{ Category.name }}">
  100.         </div>
  101.         </figure>
  102.         {% endif %}
  103.         <div class="s-content">
  104.         <h2 class="s-title">{{ Category.name }}の業務用エアコンの特長</h2>
  105.         {% if Category and Category.free_area %}
  106.         <div class="s-text">
  107.             {{ include(template_from_string(Category. free_area)) }}
  108.         </div>
  109.         {% endif %}
  110.         </div>
  111.     </div>
  112. </div>
  113. {% endif %}
  114. {% endblock %}
  115. {% block main %}
  116. <div class="c-section">
  117.     <h3 class="c-title-07"><span class="s-text">{% if cnt == 1 %}{{ Category.name }}のエアコン{% endif %}商品一覧</span></h3>
  118.     {% if search_form.category_id.vars.errors|length > 0 %}
  119.     <div class="ec-searchnavRole">
  120.         <p class="errormsg text-danger">{{ 'ご指定のカテゴリは存在しません'|trans }}</p>
  121.     </div>
  122.     {% else %}
  123.     <div class="ec-searchnavRole">
  124.         <form name="form1" id="form1" method="get" action="?">
  125.             {% for item in search_form %}
  126.                 {# タグの複数検索に対応 @see https://umebius.com/eccube/product_list_tag_search/ #}
  127.                 {% if item.vars.value is iterable %}
  128.                     {% for val in item.vars.value %}
  129.                     <input type="hidden" id="{{ item.vars.id }}"
  130.             name="{{ item.vars.full_name }}[]" value="{{ val }}"/>
  131.                     {% endfor %}
  132.                 {% else %}
  133.                     <input type="hidden" id="{{ item.vars.id }}"
  134.             name="{{ item.vars.full_name }}"
  135.             {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  136.                 {% endif %}
  137.             {% endfor %}
  138.         </form>
  139.         <div class="p-products-list-head">
  140.         {% if pagination.totalItemCount > 0 %}
  141.             <div class="c-total-wrap">
  142.             {{ '<p class="c-total-num"><span class="s-main font-en">%count%</span><span class="s-sub">件</span></p>の商品がございます'|trans({ '%count%': pagination.totalItemCount })|raw }}
  143.             </div>
  144.             <div class="c-change-num">
  145.             <span class="s-text">表示件数</span>
  146.             {{ form_widget(search_form.disp_number, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  147.             </div>
  148.         {% else %}
  149.             <div class="c-total-wrap"><span>{{ 'お探しの商品は見つかりませんでした'|trans }}</span></div>
  150.         {% endif %}
  151.         </div>
  152.     </div>
  153.     {% if pagination.totalItemCount > 0 %}
  154.     <div class="ec-shelfRole">
  155.         <ul class="p-products-list">
  156.         {% for Product in pagination %}
  157.             {% set CatId = '' %}
  158.             {% set CatMaker = '' %}{# メーカー #}
  159.             {% set CatSeriesId = '' %}{# シリーズID #}
  160.             {% set CatShape = '' %}{# 形状 #}
  161.             {% set CatPower = '' %}{# 馬力 #}
  162.             {% set TagPower1 = '' %}{# 電源1 #}
  163.             {% set TagPower2 = '' %}{# 電源2 #}
  164.             {% set ProductCode = '' %}{# 型番 #}
  165.             {% set HiddenFlag = '0' %}{# 非表示フラグ #}
  166.             {# カテゴリ #}
  167.             {% if Product.ProductCategories is not empty %}
  168.                 {% for ProductCategory in Product.ProductCategories %}
  169.                     {% if ProductCategory.Category.getParent is not null %}
  170.                         {% if ProductCategory.Category.getParent.id == 1 %}
  171.                             {% set CatMaker = ProductCategory.Category.name %}{# メーカー #}
  172.                             {% set CatId = ProductCategory.Category.id %}
  173.                         {% endif %}
  174.                         {% if ProductCategory.Category.getParent.id == 51 %}
  175.                             {% set CatShape = ProductCategory.Category.id %}{# 形状 #}
  176.                         {% endif %}
  177.                         {% if ProductCategory.Category.getParent.id == 61 %}
  178.                             {% set CatPower = ProductCategory.Category.id %}{# 馬力 #}
  179.                         {% endif %}
  180.                     {% endif %}
  181.                     {% if CatId is not empty %}
  182.                         {% if ProductCategory.Category.getParent is not null %}
  183.                             {% if ProductCategory.Category.getParent.id == CatId %}
  184.                                 {% set CatSeriesId = ProductCategory.Category.id %}{# シリーズID #}
  185.                                 {%  set Category = repository('Eccube\\Entity\\Category').find(CatSeriesId) %}
  186.                                 {%  set HiddenFlag = Category.hidden_flag %}
  187.                             {% endif %}
  188.                         {% endif %}
  189.                     {% endif %}
  190.                 {% endfor %}
  191.             {% endif %}
  192.             {# タグ:電源 #}
  193.             {% if Product.hasTag(1) %}
  194.             {% set PageTag = repository('Eccube\\Entity\\Tag').find('1') %}
  195.             {% set TagPower1 = PageTag.name %}{# 電源1 #}
  196.             {% endif %}
  197.             {% if Product.hasTag(2) %}
  198.             {% set PageTag = repository('Eccube\\Entity\\Tag').find('2') %}
  199.             {% set TagPower2 = PageTag.name %}{# 電源2 #}
  200.             {% endif %}
  201.             {# 型番 #}
  202.             {% if Product.code_min is not empty %}
  203.             {% set ProductCode = Product.code_min %}{# 型番 #}
  204.             {% endif %}
  205.             <li class="p-products-item">
  206.                 <figure class="s-image">
  207.                     {# <a href="{{ url('product_detail', {'id': Product.id}) }}?shape={{ CatShape }}&power={{ CatPower }}"> #}
  208.                     <a href="{{ url('product_detail', {'id': Product.id}) }}">
  209.                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" alt="{{ Product.name }}" {% if loop.index > 5 %} loading="lazy"{% endif %}>
  210.                     </a>
  211.                 </figure>
  212.                 <div class="s-content">
  213.                     {# <h4 class="s-title"><a href="{{ url('product_detail', {'id': Product.id}) }}?shape={{ CatShape }}&power={{ CatPower }}">{{ CatMaker }} {{ Product.name }}</a></h4> #}
  214.                     <h4 class="s-title"><a href="{{ url('product_detail', {'id': Product.id}) }}">{{ CatMaker }} {{ Product.name }}</a></h4>
  215.                     <table class="c-table-04">
  216.                         <tr>
  217.                         <th class="s-col1">型番</th>
  218.                         <th class="s-col2">定価(税込)</th>
  219.                         <th class="s-col3">販売価格(税込)</th>
  220.                         </tr>
  221.                         <tr>
  222.                         <td>
  223.                         {{ ProductCode }}
  224.                         </td>
  225.                         <td>
  226.                             <p class="p-products-text01"><span class="s-main font-en">
  227.                         {{ Product.getPrice01IncTaxMin|number_format }}
  228.                             </span>円</p>
  229.                         </td>
  230.                         <td>
  231.                             <div class="p-products-list-price02-wrap">
  232.                             {% set price01 = Product.getPrice01IncTaxMin %}
  233.                             {% set price02 = Product.getPrice02IncTaxMin %}
  234.                             {% if price01 != '' %}
  235.                                 <p class="p-products-label01"><span class="font-en">
  236.                                 <span class="s-main">
  237.                                 {% set price03 = (1-(price02 / price01))*100|round(1, 'ceil') %}
  238.                                 {{ price03|number_format(1, '.', ',') }}
  239.                                 </span>%</span><br class="no-pc">割引</p>
  240.                             {% endif %}
  241.                                 <p class="p-products-text02"><span class="s-main font-en">
  242.                                 {{ Product.getPrice02IncTaxMin|number_format }}
  243.                                 </span>円</p>
  244.                             </div>
  245.                         </td>
  246.                         </tr>
  247.                     </table>
  248.                 </div>
  249.             </li>
  250.             {% endfor %}
  251.         </ul>
  252.     </div>
  253.     <div class="ec-pagerRole">
  254.         {% include "pager.twig" with {'pages': pagination.paginationData} %}
  255.     </div>
  256.     {% endif %}
  257.     {% endif %}
  258. </div>
  259. {% endblock %}