diff --git a/resources/views/category/overview.blade.php b/resources/views/category/overview.blade.php index 01db3da39..66d16e8be 100644 --- a/resources/views/category/overview.blade.php +++ b/resources/views/category/overview.blade.php @@ -2,7 +2,18 @@ @section('title', $category->meta_title ?: $category->name) @section('description', $category->meta_description) -@section('canonical', url($category->url)) +@if ($category->is_anchor) + @php + $total = $category->listingProducts()->count() + @endphp + @include('rapidez::layouts.partials.head.pagination', [ + 'url' => url($category->url), + 'total' => $total, + 'perPage' => Rapidez::config('catalog/frontend/grid_per_page'), + ]) +@else + @section('canonical', url($category->url)) +@endif @include('rapidez::layouts.partials.head.hreflang', ['alternates' => $category->alternates]) @section('content') @@ -12,7 +23,7 @@

{{ $category->name }}

@if ($category->is_anchor) - @if (!$category->products()->exists()) + @if ($total == 0) @include('rapidez::listing.partials.no-products') @else 1) + + @endif + + @if ($currentPage < $lastPage) + + @endif +@endpush diff --git a/src/Models/Category.php b/src/Models/Category.php index 2fb1bd241..349b42a31 100644 --- a/src/Models/Category.php +++ b/src/Models/Category.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Rapidez\Core\Enums\EntityType; +use Rapidez\Core\Enums\Visibility; use Rapidez\Core\Facades\Rapidez; use Rapidez\Core\Models\Scopes\Category\IsActiveScope; use Rapidez\Core\Models\Traits\HasAlternatesThroughRewrites; @@ -75,6 +76,14 @@ public function products(): HasManyThrough ); } + public function listingProducts(): HasManyThrough + { + return $this->products()->whereInAttribute('visibility', [ + Visibility::Catalog->value, + Visibility::Both->value, + ]); + } + public function categoryProducts(): HasMany { return $this->hasMany(