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 2945194..0f5f595 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 %} @@ -38,22 +46,24 @@ {{ product.name }} +
{% if product.stock > 0 %} stock: {{ product.stock }} {% else %} out of stock {% endif %} {% if product.isDiscontinued() %} - is discontinued + is discontinued {% endif %} {% if product.isNew() %} - is new + is new {% endif %} {{ product.subTitle }} {% if product.promotions is not null and product.promotions.hasPromotion %}PROMO: {{ product.promotions.tag }}{% endif %} + {{ product.country.countryName }}