{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
{% set twig_img_path = absolute_url('/media/image/') %}
{% set imageSource = product.images|default(0) ? twig_img_path ~ product.images[0].path : "" %}
{% set productVariant = product.type == constant('App\\Entity\\Core\\Product::BY_BATCH') ? (product.variants|length > 1 ? product.variants[1] : null) : product.variants.first %}
{% if productVariant|default(0) %}
{% set price = productVariant.channelPricings.first.price %}
{% set originalPrice = productVariant.channelPricings.first.originalPrice %}
{% set productVariantShowPath = path('app_product_variant_show', {'_locale': app.request.locale, 'groupCode': group.code, 'productVariantCode': productVariant.code}) %}
<div class="col-sm-3 col-md-3 col-xs-12 mb-0-5r mx-0">
<div class="card">
<div class="card-img-box">
{% if imageSource %}
<a href="{{ productVariantShowPath }}">
<img alt="Card image" class="img-fluid" src="{{ imageSource }}">
</a>
{% else %}
<a href="{{ productVariantShowPath }}">
<img src="{{ asset("build/images/sin-imagen.jpg") }}" class="img-fluid"/>
</a>
{% endif %}
<a class="btn-see-product py-1 ff-os-light fs-12" href="{{ productVariantShowPath }}">
{{ "group.product_variant.buttons.show.label"|trans }}
</a>
{% if productVariant.product.canBeSold and originalPrice|default(0) and originalPrice > price %}
<label class="btn-discount py-1 ff-os-light">
-{{ (((originalPrice - price) * 100) / originalPrice)|round }}%
</label>
{% endif %}
</div>
<div class="card-body">
{# <div class="d-flex">
<h6 class="ct-blue ff-os-light text-truncate mt-3 mb-2">
{{ group.name }}
</h6>
</div> #}
<div class="d-flex">
<h6 class="ct-blue ff-os-semibold mt-3 mb-2">
{{ product.name }}
</h6>
</div>
{% if productVariant.product.canBeSold %}
<div class="d-flex">
<h6 class="ct-blue ff-os-bold text-truncate fs-18 {% if originalPrice|default(0) and originalPrice > price %} ct-red m-0 {% else %} mb-4 {% endif %}">
{{ money.convertAndFormat(price) }}
</h6>
</div>
{% if originalPrice|default(0) and originalPrice > price %}
<p class="td-lt ct-darkgray ff-os-regular fs-14">
{{ money.convertAndFormat(originalPrice) }}
</p>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endif %}