app/template/originalTemplate/Block/pickUp.twig line 1

Open in your IDE?
  1. {#
  2.     特定のカテゴリから必要な個数呼び出します。
  3.     categoryID に呼び出したいカテゴリのIDを入れます。
  4.     例)120番のカテゴリを呼びたい
  5.     {% set categoryID = 120 %}
  6.     count に呼び出したい個数を入れます。
  7.     例)7個呼びたい
  8.     {% set count = 7 %}
  9.     ※「全部呼ぶ」がわからないので、全部欲しいときはめっちゃでかい数入れてください。
  10.     99999 とか。
  11. #}
  12. {% set categoryID = 7 %}
  13. {% set count = 8 %}
  14. {% set Category = repository("Eccube\\Entity\\Category").find(categoryID) %}
  15. {%
  16. set Products = repository("Eccube\\Entity\\Product")
  17. .getQueryBuilderBySearchData({'category_id':Category})
  18. .setMaxResults(count)
  19. .getQuery()
  20. .getResult()
  21. %}
  22. {% if Products|length > 0 %}
  23. <section class="ec-role">
  24.     <div class="ec-pickUpItemRole">
  25.         {# タイトルを変更してください。不要な場合は下記3行を削除 #}
  26.         <div class="ec-secHeading">
  27.             <h1 class="ec-secHeading__ja">{{ 'ピックアップ'|trans }}</h1>
  28.         </div>
  29.         <div class="ec-pickUpItemRole__list">
  30.             {% for Product in Products %}
  31.             <div class="ec-pickUpItemRole__listItem">
  32.                 <a href="{{ url('product_detail', {'id': Product.id}) }}">
  33.                     <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  34.                     <p class="ec-pickUpItemRole__listItemTitle">{{ Product.name }}</p>
  35.                     <p class="ec-pickUpItemRole__listItemPrice">
  36.                     {% if Product.hasProductClass %}
  37.                         {% if Product.getPrice02Min == Product.getPrice02Max %}
  38.                             {{ Product.getPrice02IncTaxMin|price }}
  39.                         {% else %}
  40.                             {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  41.                         {% endif %}
  42.                     {% else %}
  43.                         {{ Product.getPrice02IncTaxMin|price }}
  44.                     {% endif %}
  45.                     </p>
  46.                 </a>
  47.             </div>
  48.             {% endfor %}
  49.         </div>
  50.         {#<div class="more_btn"><a href="{{ url('product_list', {'category_id': Category.id}) }}">VIEW MORE&nbsp;&nbsp;&nbsp;&nbsp;&gt;</a></div> #}
  51.     </div>
  52. </section>
  53. {% endif %}