{% set Category = repository("Eccube\\Entity\\Category").find(2) %}
{%
set products = repository("Eccube\\Entity\\Product")
.getQueryBuilderBySearchData({'category_id':Category})
.setMaxResults(5)
.getQuery()
.getResult()
%}
<div class="ec-role">
<div class="ec-newItemRole">
<div class="ec-newItemRole__list">
<div class="ec-newItemRole__listItem">
<div class="ec-newItemRole__listItemHeading ec-secHeading--tandem">
<span class="ec-secHeading__en">{{ 'front.block.new_item.title__en'|trans }}</span>
<span class="ec-secHeading__line"></span>
<span class="ec-secHeading__ja">{{ 'front.block.new_item.title__ja'|trans }}</span>
<a class="ec-inlineBtn--top" href="{{ url('product_list') }}">{{ 'front.block.new_item.more'|trans }}</a>
</div>
</div>
{% if products %}
{% for p in products %}
<div class="ec-newItemRole__listItem">
<a href="{{ url('product_detail', {'id': p.id}) }}">
<img src="{{ asset(p.main_list_image|no_image_product, 'save_image') }}">
<p class="ec-newItemRole__listItemTitle">{{ p.name }}</p>
</a>
</div>
{% endfor %}
{% endif %}
</div>
</div>
</div>