@php
$startIndex = $page * $productsPerPage;
$endIndex = min($startIndex + $productsPerPage, $totalProducts);
$pageProducts = $products->slice($startIndex, $productsPerPage);
$previousGroup = null;
@endphp
@foreach($pageProducts as $index => $product)
@php
// Determinar grupo actual
if ($catalogType == 'brand' && $product->brand) {
$currentGroupName = $product->brand->name;
} elseif ($catalogType == 'category' && $product->category) {
$currentGroupName = $product->category->name;
} else {
$currentGroupName = null;
}
// Mostrar encabezado de grupo si cambia
$showGroupHeader = $currentGroupName && $currentGroupName != $previousGroup;
if ($showGroupHeader) {
$previousGroup = $currentGroupName;
}
@endphp
@if($showGroupHeader)
@endif
@if($product->image_url)

@else
@endif
{{ $product->name }}
{{ $product->category->name ?? 'SIN CATEGORÍA' }}
@php
// Para REF, no usar rateType ya que tiene su propia fórmula
$useLegalRate = ($currency != 'REF' && ($rateType ?? 'real') == 'legal');
$price = $getPriceInCurrency($product, $currency, $useLegalRate);
$formattedPrice = $formatPrice($price, $currency);
@endphp
{{ $formattedPrice }}
@endforeach
@endfor