環境
ECCUBE 3.0.15
DB mysql
php 5.6
DBなどは特に初期の状態のままです。
トップページで、指定のカテゴリーに属する商品のみを表示させたいと思っております。
※件数指定で、Blockで表示させたいと思っております。
商品一覧の取得は取得できたのですが、ここから指定のカテゴリーのものを
条件分岐で表示させる部分がわかりません。
TabItemsController.php
1 2namespace Eccube\Controller\Block; 3 4 5use Eccube\Application; 6 7 8class TabItemsController 9{ 10 public function index(Application $app) 11 { 12 $newItemList = $app['orm.em']->getRepository('\Eccube\Entity\Product') 13 ->findBy( 14 array('Status' => 1, 15 'del_flg' => 0), 16 array('id' => 'DESC'), 17 8, 18 0 19 ); 20 21 //カテゴリー取得 22 $itemCateList = $app['eccube.repository.category']->getList(); 23 24 // テンプレートへ値を渡して出力させる 25 return $app['view']->render('Block/tab_items.twig', array( 26 'newItemList' => $newItemList, 27 'itemCateList' => $itemCateList 28 )); 29 } 30}
コントローラー側でカテゴリーの取得はできました(全件取得しておりますが。。。)
tab_items.twing <!--新着商品--> <div class="item_gallery"> <h4>新商品</h4> <ul class="row"> {% for newItem in newItemList %} <div class="col-sm-3 col-xs-6"> <div class="pickup_item"> <a href="{{ url('product_detail', {'id': newItem.id}) }}"> <div class="item_photo"><img src="{{ app.config.image_save_urlpath }}/{{ newItem.main_list_image|no_image_product }}"></div> <dl> <dt class="item_name">{{newItem.name}}</dt> <dd class="item_price"> {% if newItem.hasProductClass -%} {% if newItem.getPrice02Min == newItem.getPrice02Max %} <p class="normal_price"><span class="price01_default">{{ newItem.getPrice02IncTaxMin }}</span><span class="small">円</span></p> {% elseif newItem.getPrice02Min is not null and newItem.getPrice02Max is not null %} <p class="normal_price"><span class="price01_default">{{ newItem.getPrice02IncTaxMin }}</span> ~ <span class="price01_default">{{ newItem.getPrice02IncTaxMax }}</span><span class="small">円</span></p> {% endif %} {% else -%} {% if newItem.getPrice02Max is not null %} <p class="normal_price"><span class="price01_default">{{ newItem.getPrice02IncTaxMin }}</span><span class="small">円</span></p> {% endif %} {% endif -%} </dl> </a> </div> </div> {% endfor %} </ul> <ul class="row"> {% for itemCate in itemCateList %} <div class="col-sm-3 col-xs-6"> <div class="pickup_item"> <a href="{{ url('product_detail', {'id': itemCate.id}) }}"> <dl> <dt class="item_name">{{itemCate.name}}</dt> </dl> </a> </div> </div> {% endfor %} </ul> </div>
ここから先わかる方お教えして頂けますでしょうか。
宜しくお願い致します。
あなたの回答
tips
プレビュー