use Cubist\Backpack\app\Magic\Menu\Menu;
use Cubist\Backpack\app\Magic\Models\CubistMagicPageModel;
use Cubist\Backpack\app\Magic\Util;
+use Cubist\Backpack\Facades\App;
use Cubist\Util\Json;
-use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;
use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\Models\Media;
}) : 0;
}
+ public function renderLink()
+ {
+ $p = $this;
+ return \cache()->remember('product_details_' . $this->id . '_' . App::getLocale() . '_' . App::getVariant(), 3600, function () use ($p) {
+ return view('partials.product-link', ['id' => $p->id, 'product' => $p->getPageData()])->render();
+ });
+ }
+
public static function getFilteredProducts($product_type, $filter_values = [])
{
\Barryvdh\Debugbar\Facade::startMeasure('set cat data');
$cat = $data['page']->get('category');
+ \Barryvdh\Debugbar\Facade::startMeasure('set cat data ' . $cat);
$d = cache()->remember('cat_data_' . $cat . '_' . App::getVariant() . '_' . App::getLocale(), 3600, function () use ($cat) {
-
$res = [];
$productType = ProductType::find($cat);
if (!$productType) {
}
$res['product_type'] = $productType->getPageData();
- $products = Product::with('media') // Eager load media to avoid N+1 query problem
- ->whereVariant()
+ $res['products'] = Product::whereVariant()
->where('product_type', $cat)
->where('online', 1)
->where('public', 1)
->orderBy('reference')
->get();
- $res['products'] = PageData::fromEntities($products);
-
// Get available filters
$filters = Product::getFilteredProducts($cat);
$res['filters'] = $filters ? $filters['filters'] : []; // To be used by Vue component
if (!$d) {
$this->_404();
}
+ \Barryvdh\Debugbar\Facade::stopMeasure('set cat data ' . $cat);
foreach ($d as $k => $v) {
$data[$k] = $v;
"composer/installers": true
},
"platform": {
- "php": "7.4"
+ "php": "8.0"
}
},
"extra": {
{{-- Product Grid --}}
<grid cols="auto" class="products-grid mt-6 sm:mt-2">
@foreach($products as $id => $product)
- @include('partials.product-link', ['id' => $id, 'product' => $product])
+ {!!$product->renderLink()!!}
@endforeach
</grid>