環境
ECCUBE 3.0.15
DB mysql
php 5.6
DBなどは特に初期の状態のままです。
トップページで、指定のカテゴリーに属する商品のみを表示させたいと思っております。
※件数指定で、Blockで表示させたいと思っております。
商品一覧の取得は取得できたのですが、ここから指定のカテゴリーのものを
条件分岐で表示させる部分がわかりません。
namespace Eccube\Controller\Block;
use Eccube\Application;
class TabItemsController
{
public function index(Application $app)
{
$newItemList = $app['orm.em']->getRepository('\Eccube\Entity\Product')
->findBy(
array('Status' => 1,
'del_flg' => 0),
array('id' => 'DESC'),
8,
0
);
//カテゴリー取得
$itemCateList = $app['eccube.repository.category']->getList();
// テンプレートへ値を渡して出力させる
return $app['view']->render('Block/tab_items.twig', array(
'newItemList' => $newItemList,
'itemCateList' => $itemCateList
));
}
}
コントローラー側でカテゴリーの取得はできました(全件取得しておりますが。。。)
<!--新着商品-->
<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>
</div>
ここから先わかる方お教えして頂けますでしょうか。
宜しくお願い致します。