@if (is_plugin_active('marketplace'))
@php
/**
* Vendor list partial.
* Used as both server-render in views/marketplace/stores.blade.php AND as
* AJAX fragment for infinite scroll / load-more.
*
* Inputs:
* $stores iterable<\Botble\Marketplace\Models\Store> (required)
*/
$reviewsEnabled = class_exists(\Botble\Ecommerce\Facades\EcommerceHelper::class)
&& \Botble\Ecommerce\Facades\EcommerceHelper::isReviewEnabled();
$hideAddress = class_exists(\Botble\Marketplace\Facades\MarketplaceHelper::class)
&& \Botble\Marketplace\Facades\MarketplaceHelper::hideStoreAddress();
// Batch-resolve product counts in a single query — plugin's PublicStoreController
// doesn't withCount('products'), so we attach it theme-side without N+1.
$storeItems = method_exists($stores, 'items') ? $stores->items() : (is_iterable($stores) ? $stores : []);
$storeIds = collect($storeItems)->pluck('id')->filter()->all();
$countsByStore = $storeIds
? \Botble\Ecommerce\Models\Product::query()
->whereIn('store_id', $storeIds)
->where('is_variation', 0)
->wherePublished()
->selectRaw('store_id, COUNT(*) as c')
->groupBy('store_id')
->pluck('c', 'store_id')
: collect();
@endphp
@if ((is_countable($stores) ? count($stores) : 0) > 0)
{{ __('No vendors found.') }}
@endif
@endif