From e68389bccc6bd1cb61673eae5108c81ea5342b96 Mon Sep 17 00:00:00 2001 From: Krzysiej Date: Mon, 16 Feb 2026 08:59:46 +0100 Subject: [PATCH] Add locale badges to promos --- src/Controller/PromosController.php | 5 ++++- templates/productList.html.twig | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Controller/PromosController.php b/src/Controller/PromosController.php index f3f277f..8e5fe05 100644 --- a/src/Controller/PromosController.php +++ b/src/Controller/PromosController.php @@ -20,8 +20,11 @@ final class PromosController extends BaseController $promos = Product::select($this->database->getConnection()->raw("distinct json_extract(promotions, '$.slug') as slug, json_extract(promotions, '$.tag') as tag")) + ->addSelect('countries.locale') ->whereRaw("json_extract(promotions, '$.tag') is not null") - ->get(); + ->join('countries', 'products.country_id', '=', 'countries.id') + ->get() + ->groupBy('locale'); return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos' . $promo, 'promos' => $promos->toArray()]); } diff --git a/templates/productList.html.twig b/templates/productList.html.twig index f0c74d8..687ca59 100644 --- a/templates/productList.html.twig +++ b/templates/productList.html.twig @@ -6,9 +6,17 @@ {% endif %} {% if listType starts with 'promos' %} - {% for promo in promos %} - PROMO: {{ promo.tag }} - {% endfor %} + {% endif %}