やりたいこと
EC-CUBEのトップページで、登録している商品の一覧を表示したい。
試したこと
デフォルト(app/template/default/Product)にあるlist.twigの{% javascript %},{% block main %}の中身をindex.twigに転記↓
twig
1{% extends 'default_frame.twig' %} 2 3{% set body_class = 'front_page' %} 4 5{% block javascript %} 6<script> 7// 並び順を変更 8function fnChangeOrderBy(orderby) { 9 eccube.setValue('orderby', orderby); 10 eccube.setValue('pageno', 1); 11 eccube.submitForm(); 12} 13 14// 表示件数を変更 15function fnChangeDispNumber(dispNumber) { 16 eccube.setValue('disp_number', dispNumber); 17 eccube.setValue('pageno', 1); 18 eccube.submitForm(); 19} 20// 商品表示BOXの高さを揃える 21$(window).load(function() { 22 $('.product_item').matchHeight(); 23}); 24 25$(function(){ 26 $('.main_visual').slick({ 27 dots: true, 28 arrows: false, 29 autoplay: true, 30 speed: 300 31 }); 32}); 33</script> 34{% endblock %} 35 36{% block main %} 37 {% if search_form.category_id.vars.errors|length == 0 %} 38 <form name="form1" id="form1" method="get" action="?"> 39 {{ form_widget(search_form) }} 40 </form> 41 <!-- ▼topicpath▼ --> 42 <div id="topicpath" class="row"> 43 <ol id="list_header_menu"> 44 <li><a href="{{ url('product_list') }}">全商品</a></li> 45 {% if Category is not null %} 46 {% for Path in Category.path %} 47 <li><a href="{{ url('product_list') }}?category_id={{ Path.id }}">{{ Path.name }}</a></li> 48 {% endfor %} 49 {% endif %} 50 {% if search_form.vars.value.name %} 51 <li>「{{ search_form.vars.value.name }}」の検索結果</li> 52 {% endif %} 53 </ol> 54 </div> 55 <!-- ▲topicpath▲ --> 56 <div id="result_info_box" class="row"> 57 <form name="page_navi_top" id="page_navi_top" action="?"> 58 {% if pagination.totalItemCount > 0 %} 59 <p id="result_info_box__item_count" class="intro col-sm-6"><strong><span id="productscount">{{ pagination.totalItemCount }}</span>件</strong>の商品がみつかりました。 60 </p> 61 62 <div id="result_info_box__menu_box" class="col-sm-6 no-padding"> 63 <ul id="result_info_box__menu" class="pagenumberarea clearfix"> 64 <li id="result_info_box__disp_menu"> 65 {{ form_widget(disp_number_form, {'id': '', 'attr': {'onchange': "javascript:fnChangeDispNumber(this.value);"}}) }} 66 </li> 67 <li id="result_info_box__order_menu"> 68 {{ form_widget(order_by_form, {'id': '', 'attr': {'onchange': "javascript:fnChangeOrderBy(this.value);"}}) }} 69 </li> 70 </ul> 71 </div> 72 73 {% for f in disp_number_form.getIterator %} 74 {% if f.vars.name matches '[^plg*]' %} 75 {{ form_label(f) }} 76 {{ form_widget(f) }} 77 {{ form_errors(f) }} 78 {% endif %} 79 {% endfor %} 80 81 {% for f in order_by_form.getIterator %} 82 {% if f.vars.name matches '[^plg*]' %} 83 {{ form_label(f) }} 84 {{ form_widget(f) }} 85 {{ form_errors(f) }} 86 {% endif %} 87 {% endfor %} 88 {% else %} 89 <p id="result_info_box__item_count" class="intro col-sm-6"><strong style="display: none;"><span id="productscount">{{ pagination.totalItemCount }}</span>件</strong>お探しの商品は見つかりませんでした。</p> 90 {% endif %} 91 </form> 92 </div> 93 94 <!-- ▼item_list▼ --> 95 <div id="item_list"> 96 <div class="row no-padding"> 97 {% for Product in pagination %} 98 <div id="result_list_box--{{ Product.id }}" class="col-sm-3 col-xs-6"> 99 <div id="result_list__item--{{ Product.id }}" class="product_item"> 100 <a href="{{ url('product_detail', {'id': Product.id}) }}"> 101 <div id="result_list__image--{{ Product.id }}" class="item_photo"> 102 <img src="{{ app.config.image_save_urlpath }}/{{ Product.main_list_image|no_image_product }}"> 103 </div> 104 <dl id="result_list__detail--{{ Product.id }}"> 105 <dt id="result_list__name--{{ Product.id }}" class="item_name">{{ Product.name }}</dt> 106 {% if Product.description_list %} 107 <dd id="result_list__description_list--{{ Product.id }}" class="item_comment">{{ Product.description_list|raw|nl2br }}</dd> 108 {% endif %} 109 {% if Product.hasProductClass %} 110 {% if Product.getPrice02Min == Product.getPrice02Max %} 111 <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price"> 112 {{ Product.getPrice02IncTaxMin|price }} 113 </dd> 114 {% else %} 115 <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price"> 116 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }} 117 </dd> 118 {% endif %} 119 {% else %} 120 <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price">{{ Product.getPrice02IncTaxMin|price }}</dd> 121 {% endif %} 122 </dl> 123 </a> 124 </div> 125 </div> 126 {% endfor %} 127 </div> 128 129 </div> 130 <!-- ▲item_list▲ --> 131 {% if pagination.totalItemCount > 0 %} 132 {% include "pagination.twig" with { 'pages' : pagination.paginationData } %} 133 {% endif %} 134 {% else %} 135 <p class="errormsg text-danger">ご指定のカテゴリは存在しません。</p> 136 {% endif %} 137{% endblock %}
結果
トップページにアクセスした際に、システムにエラーが出ました。と表示されました。
商品一覧を表示する方法は、なんでもよいのですが、有識者の方、良ければ教えていただきたいです
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。