✨ feat(Product): Ajoute la génération de slug pour les produits.
🐛 fix(ReserverController): Corrige la route de la sitemap. ♻️ refactor(SiteMapListener): Génère les URLs des produits dans la sitemap. 🔧 chore(ansible): Ajoute le dossier seo aux dossiers à sauvegarder.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Account;
|
||||
use App\Entity\AccountResetPasswordRequest;
|
||||
use App\Entity\Product;
|
||||
use App\Form\RequestPasswordConfirmType;
|
||||
use App\Form\RequestPasswordRequestType;
|
||||
use App\Logger\AppLogger;
|
||||
@@ -40,7 +41,7 @@ class ReserverController extends AbstractController
|
||||
$robots->disallow('/payment');
|
||||
$robots->crawlDelay(60);
|
||||
$robots->allow('/reservation');
|
||||
$robots->sitemap($request->getSchemeAndHttpHost().$this->generateUrl('PrestaSitemapBundle_index',['_format' => 'xml']));
|
||||
$robots->sitemap($request->getSchemeAndHttpHost().'/seo/sitemap.xml');
|
||||
|
||||
return new Response($robots->toString(),Response::HTTP_OK,[
|
||||
'Content-Type' => 'text/plain'
|
||||
@@ -63,10 +64,30 @@ class ReserverController extends AbstractController
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/produit/{id}', name: 'reservation_product_show')]
|
||||
public function revervationShowProduct(ProductRepository $productRepository): Response
|
||||
public function revervationShowProduct(string $id, ProductRepository $productRepository): Response
|
||||
{
|
||||
// 1. Extraction de l'ID (ex: "15-chateau-fort" -> 15)
|
||||
$parts = explode('-', $id);
|
||||
$realId = $parts[0]; // Récupère le tout premier élément (l'index 0)
|
||||
|
||||
// 2. Récupération du produit par son ID numérique
|
||||
$product = $productRepository->find($realId);
|
||||
|
||||
if (!$product) {
|
||||
throw $this->createNotFoundException('Produit introuvable');
|
||||
}
|
||||
|
||||
// 3. Logique des suggestions (inchangée)
|
||||
$allInCat = $productRepository->findBy(['category' => $product->getCategory()], [], 5);
|
||||
|
||||
$otherProducts = array_filter($allInCat, function($p) use ($product) {
|
||||
return $p->getId() !== $product->getId();
|
||||
});
|
||||
|
||||
return $this->render('revervation/produit.twig', [
|
||||
'product' => $product,
|
||||
'otherProducts' => array_slice($otherProducts, 0, 4)
|
||||
]);
|
||||
}
|
||||
#[Route('/reservation/contact', name: 'reservation_contact')]
|
||||
public function revervationContact(Request $request, Mailer $mailer): Response
|
||||
|
||||
Reference in New Issue
Block a user