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 %} +