{% sw_extends '@Storefront/storefront/component/product/listing.html.twig' %}
{% block element_product_listing_col %}
{# this option cannot be used with GrimmTheme, causes conflict with other plugins like list view #}
{% if config('S360Experts.config.showInListing') and not config('GrimmTheme') %}
{% set config = config('S360Experts.config') %}
{% set showExpert = false %}
{% if config.showInListing and page.hasExtension('s360_experts') %}
{% set showExpert = true %}
{% endif %}
{% set asProductTileInt = config.asProductTileInt %}
{% if config.asProductTileInt is same as(0) %}
{% set asProductTileInt = 1 %}
{% endif %}
{% set hasShownExpert = false %}
{% if page.getExtension('s360_experts_images').all is not empty %}
{% set s360ExpertsImages = searchMedia(page.getExtension('s360_experts_images').all, context.context) %}
{% endif %}
{% for product in searchResult %}
{% if showExpert and config.asProductTileInt is same as(0) and loop.index is same as(1) %}
<div class="cms-listing-col {{ listingColumns }} s360-experts is--listing">
{% sw_include '@Storefront/solution360/s360experts/category-product.html.twig' with { 'expert': page.getExtension('s360_experts').first() } %}
</div>
{% endif %}
<div class="cms-listing-col {{ listingColumns }}">
{% block element_product_listing_box %}
{{ parent() }}
{% endblock %}
</div>
{% if showExpert and asProductTileInt is same as (loop.index) and config.asProductTileInt is not same as(0) %}
<div class="cms-listing-col {{ listingColumns }} s360-experts is--listing">
{% sw_include '@Storefront/solution360/s360experts/category-product.html.twig' with { 'expert': page.getExtension('s360_experts').first() } %}
</div>
{% endif %}
{% if showExpert and config.asProductTileInt > searchResult|length and loop.last is same as(true) %}
<div class="cms-listing-col {{ listingColumns }} s360-experts is--listing">
{% sw_include '@Storefront/solution360/s360experts/category-product.html.twig' with { 'expert': page.getExtension('s360_experts').first() } %}
</div>
{% endif %}
{% endfor %}
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}