app/template/default/Block/pickup_maker.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. {# デザイン確認用: dtb_pickup_makerを使わず、メーカーと商品を直接取得 #}
  9. {% set Makers = repository('Plugin\\Maker42\\Entity\\Maker').findBy({}, {sort_no: 'desc'}, 3) %}
  10. {% set pickupMakers = [] %}
  11. {% for Maker in Makers %}
  12.     {% set products = repository('Eccube\\Entity\\Product').findBy({'Maker': Maker, 'Status': 1}, {'create_date': 'DESC'}, 1000) %}
  13.     {% set inStockProducts = [] %}
  14.     {% for p in products %}
  15.         {% if p.main_list_image and p.getStockMax > 0 and inStockProducts|length < 10 %}
  16.             {% set inStockProducts = inStockProducts|merge([p]) %}
  17.         {% endif %}
  18.     {% endfor %}
  19.     {% if inStockProducts|length > 0 %}
  20.         {% set pickupMakers = pickupMakers|merge([{'maker': Maker, 'products': inStockProducts}]) %}
  21.     {% endif %}
  22. {% endfor %}
  23. {% if pickupMakers|length > 0 %}
  24. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
  25. <style>
  26.     .pickup-maker-section {
  27.         margin-bottom: 40px;
  28.     }
  29.     .pickup-maker-header {
  30.         margin-bottom: 16px;
  31.         padding: 0 4px;
  32.     }
  33.     .pickup-maker-header h3 {
  34.         display: flex;
  35.         align-items: center;
  36.         gap: 8px;
  37.         font-size: 1.2rem;
  38.         font-weight: bold;
  39.         margin: 0;
  40.     }
  41.     .pickup-maker-header__logo {
  42.         width: 64px !important;
  43.         height: 64px !important;
  44.         object-fit: contain;
  45.     }
  46.     .pickup-maker-more {
  47.         text-align: right;
  48.         margin-top: 12px;
  49.         padding: 0 4px;
  50.     }
  51.     .pickup-maker-swiper {
  52.         position: relative;
  53.         padding: 0 40px;
  54.     }
  55.     .pickup-maker-swiper .swiper-button-prev,
  56.     .pickup-maker-swiper .swiper-button-next {
  57.         color: #333;
  58.         width: 32px;
  59.         height: 32px;
  60.     }
  61.     .pickup-maker-swiper .swiper-button-prev::after,
  62.     .pickup-maker-swiper .swiper-button-next::after {
  63.         font-size: 16px;
  64.     }
  65.     .pickup-maker-swiper .swiper-button-prev {
  66.         left: 0;
  67.     }
  68.     .pickup-maker-swiper .swiper-button-next {
  69.         right: 0;
  70.     }
  71.     .pickup-maker-swiper .ec-shelfGrid__item {
  72.         width: 100%;
  73.         margin-bottom: 0;
  74.         padding: 0;
  75.     }
  76.     @media (max-width: 767px) {
  77.         .pickup-maker-swiper {
  78.             padding: 0 30px;
  79.         }
  80.     }
  81. </style>
  82. <div class="ec-role">
  83.     <div class="pickup_maker">
  84.         <h2 class="top_title">ピックアップメーカー</h2>
  85.         {% for entry in pickupMakers %}
  86.             <div class="pickup-maker-section">
  87.                 <div class="pickup-maker-header">
  88.                     <h3>
  89.                         <a class="text-decoration-none" href="{{ url('product_list') }}?maker_id={{ entry.maker.id }}">
  90.                             <img class="pickup-maker-header__logo" src="{{ asset('assets/img/maker/' ~ entry.maker.id ~ '.png', 'user_data') }}" alt="{{ entry.maker.name }}" loading="lazy">
  91.                             {{ entry.maker.name }}
  92.                         </a>
  93.                     </h3>
  94.                 </div>
  95.                 <div class="pickup-maker-swiper">
  96.                     <div class="swiper pickup-maker-swiper-{{ loop.index }}">
  97.                         <div class="swiper-wrapper">
  98.                             {% for Product in entry.products %}
  99.                                 <div class="swiper-slide">
  100.                                     <div class="ec-shelfGrid__item">
  101.                                         <a href="{{ url('product_detail', {'id': Product.id}) }}">
  102.                                             <p class="ec-shelfGrid__item-image">
  103.                                                 <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}"
  104.                                                      alt="{{ Product.name }}" loading="lazy" class="w-auto">
  105.                                             </p>
  106.                                             <dl>
  107.                                                 <dt class="fs-6 item_name">{{ Product.name }}</dt>
  108.                                             </dl>
  109.                                         </a>
  110.                                         <div class="ec-shelfGrid__item-buttom">
  111.                                             {{ include('Block/product_list_price.twig', {Product: Product}, ignore_missing = true) }}
  112.                                             {{ include('Block/product_code.twig', {Product: Product}, ignore_missing = true) }}
  113.                                             {{ include('Block/stock.twig', {Product: Product}, ignore_missing = true) }}
  114.                                         </div>
  115.                                     </div>
  116.                                 </div>
  117.                             {% endfor %}
  118.                         </div>
  119.                     </div>
  120.                     <div class="swiper-button-prev swiper-button-prev-{{ loop.index }}"></div>
  121.                     <div class="swiper-button-next swiper-button-next-{{ loop.index }}"></div>
  122.                 </div>
  123.                 <div class="pickup-maker-more">
  124.                     <a class="btn-metro-color px-5 py-2 fs-6" href="{{ url('product_list') }}?maker_id={{ entry.maker.id }}">もっと見る</a>
  125.                 </div>
  126.             </div>
  127.         {% endfor %}
  128.     </div>
  129. </div>
  130. <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
  131. <script>
  132.     document.addEventListener('DOMContentLoaded', function() {
  133.         {% for entry in pickupMakers %}
  134.             new Swiper('.pickup-maker-swiper-{{ loop.index }}', {
  135.                 slidesPerView: 2,
  136.                 spaceBetween: 12,
  137.                 navigation: {
  138.                     prevEl: '.swiper-button-prev-{{ loop.index }}',
  139.                     nextEl: '.swiper-button-next-{{ loop.index }}',
  140.                 },
  141.                 breakpoints: {
  142.                     768: {
  143.                         slidesPerView: 4,
  144.                         spaceBetween: 16,
  145.                     },
  146.                     1024: {
  147.                         slidesPerView: 5,
  148.                         spaceBetween: 20,
  149.                     },
  150.                 },
  151.             });
  152.         {% endfor %}
  153.     });
  154. </script>
  155. {% endif %}