diff --git a/src/Controller/ShopController.php b/src/Controller/ShopController.php index a137b83..c1ddc4b 100644 --- a/src/Controller/ShopController.php +++ b/src/Controller/ShopController.php @@ -47,10 +47,19 @@ class ShopController extends AbstractController } #[Route(path: '/boutique/produit/{slug}', name: 'app_product_show', options: ['sitemap' => false], methods: ['GET'])] - public function indexProductShow(): Response + public function indexProductShow(?string $slug,ProductsRepository $productsRepository): Response { - return $this->render('shop.twig', [ - 'featuredProducts' => [] + if(is_null($slug)) { + return $this->redirectToRoute('app_shop'); + } + $slug = explode('-', $slug); + $endId = end($slug); + if(!is_numeric($endId)) { + return $this->redirectToRoute('app_shop'); + } + $p = $productsRepository->find($endId); + return $this->render('shop/product_details.twig', [ + 'product' => $p ]); } } diff --git a/templates/event.twig b/templates/event.twig index 4181330..db6743a 100644 --- a/templates/event.twig +++ b/templates/event.twig @@ -34,17 +34,6 @@ {{ 'events.list_main_title'|trans|default('Upcoming Events') }} - {# - --- Events List Block --- - This section assumes an 'events' iterable variable is passed to the template. - Each item in 'events' is expected to be an object/array with: - - title (string) - - start_date (DateTime object) - - end_date (DateTime object) - - location (string) - - organizer (string) - - id (int/string for link) - #} {% if events is defined and events is not empty %}
diff --git a/templates/shop.twig b/templates/shop.twig index ac5784c..f489d87 100644 --- a/templates/shop.twig +++ b/templates/shop.twig @@ -83,7 +83,7 @@ }, "offers": { "@type": "Offer", - "url": "{{ app.request.schemeAndHttpHost }}{{ path('app_product_show', {'slug': product.name|lower|replace({' ': '-'})}) }}", + "url": "{{ app.request.schemeAndHttpHost }}{{ path('app_product_show',{'slug': (product.name|lower|replace({' ': '-'}))~"-"~product.id}) }}", "priceCurrency": "EUR", "price": "{{ product.price }}", "itemCondition": "https://schema.org/{% if product.state == 'new' %}NewCondition{% else %}UsedCondition{% endif %}", @@ -167,7 +167,7 @@ {{ product.price | number_format(2, ',', ' ') }} € TTC - En savoir plus diff --git a/templates/shop/product_details.twig b/templates/shop/product_details.twig new file mode 100644 index 0000000..e530474 --- /dev/null +++ b/templates/shop/product_details.twig @@ -0,0 +1,201 @@ +{% extends 'base.twig' %} + +{# --- METADATA & SCHEMA --- #} +{% block title %}{{ product.name }}{% endblock %} +{% block meta_description %}{{ product.shortDescription }}{% endblock %} + +{% block canonical_url %}{% endblock %} +{% block breadcrumb_schema %} + + + +{% endblock %} + +{# --- BODY --- #} +{% block body %} + {# Ajout d'une balise style pour définir les couleurs personnalisées du bouton #} + + +
+ {# Conteneur simplifié et épuré #} +
+ {# Titre H1 #} +

+ {{ product.name }} +

+ +
+ {# --- Product Image (Left Column on Desktop) --- #} +
+ {{ product.name }} +
+ + {# --- Product Details & Actions (Right Column on Desktop) --- #} +
+ {# --- Price (Simple TTC Display) --- #} +
+

+ {{ product.price|number_format(2, ',', ' ') }} € TTC +

+
+ + {# --- Short Description --- #} +
+

+ {{ product.shortDescription }} +

+
+ + {# --- Reference and Custom/Handmade Tags --- #} +
+ {# Product Reference #} +

+ {{ 'product_ref'|trans }}: {{ product.ref }} +

+ + {# Custom / Fait Main Badges #} +
+ {% if product.handmade %} + + {{ 'product_handmade'|trans }} + + {% endif %} + + {% if product.custom %} + + {{ 'product_custom'|trans }} + + {% endif %} +
+
+ + {# --- Action: Add to Cart Button (Updated with custom yellow class) --- #} + + + {# Messages de livraison/stock traduits #} +
+

{{ 'product_estimated_delivery'|trans }}

+

{{ 'product_shipping_methods'|trans }}

+
+ +
+
+ + {# --- Long Description (Full Width Below) --- #} +
+

{{'product_long_desc_title'|trans}}

+
+ {{ product.longDescription|raw }} +
+
+
+
+{% endblock %} diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index f9cca89..b51978f 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -663,3 +663,18 @@ event_website_launch_date: "November 15, 2025" event_website_launch_title: "Website Launch" event_website_launch_text: "Launch of our official platform to inform about our activities, manage registrations, and share our creations." timeline_title: "Our Timeline" +# --- New Product Page Keys --- +product_add_to_cart: "Add to Cart" +product_ref: "Reference" +product_state: "Condition" +product_state_new: "New" +product_state_used: "Used" +product_features_title: "Features" +product_handmade: "Handmade (Artisanal)" +product_not_handmade: "Industrial/Manufactured" +product_custom: "Unique Piece (Custom)" +product_not_custom: "Standard Item" +product_short_desc_title: "Quick Overview" +product_long_desc_title: "Detailed Description" +product_estimated_delivery: "Estimated delivery: 2-5 working days." +product_shipping_methods: "Shipping via Mondial Relay / Colissimo starting from €6 incl. tax" diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index cb33294..e6368ac 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -597,3 +597,17 @@ event_miss_tergnier_text: "Signature du partenariat avec Miss Tergnier 2025." event_website_launch_date: "15 novembre, 2025" event_website_launch_title: "Lancement du Site Internet" event_website_launch_text: "Mise en ligne de notre plateforme officielle pour informer sur nos activités, gérer les inscriptions et partager nos créations." +product_add_to_cart: "Ajouter au panier" +product_ref: "Référence" +product_state: "État" +product_state_new: "Neuf" +product_state_used: "Occasion" +product_features_title: "Caractéristiques" +product_handmade: "Fait Main (Artisanal)" +product_not_handmade: "Industriel/Manufacturé" +product_custom: "Pièce Unique (Sur Mesure)" +product_not_custom: "Article Standard" +product_short_desc_title: "Aperçu rapide" +product_long_desc_title: "Description détaillée" +product_estimated_delivery: "Livraison estimée : 2-5 jours ouvrés." +product_shipping_methods: "Livraison par Mondial Relay / Colissimo à partir de 6€ TTC"