Alex--77 Posted March 7, 2016 Share Posted March 7, 2016 (edited) Bonjour, Lorsque je désactive un produit, je souhaiterais afficher la page 404 que j'ai personnalisé. Voici les manip que j'ai fait : - Désactiver le produit dans le BO - Rediriger lorsque inactif : j'ai choisit "pas de redirection (404)". Mais lorsque je sélection cette option, j'ai un affichage pas très propre et j'ai le texte :"Il y a 1 erreur. Ce produit n'est plus disponible.". Ce n'est pas la page que j'ai personnalisé (404.tpl). Dans le fichier ProductController.php, j'ai repéré ceux-ci : switch ($this->product->redirect_type) { case '301': header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected)); exit; break; case '302': header('HTTP/1.1 302 Moved Temporarily'); header('Cache-Control: no-cache'); header('Location: '.$this->context->link->getProductLink($this->product->id_product_redirected)); exit; break; case '404': default: header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('This product is no longer available.'); break; Je ne trouve pas comment faire appel à la page 404.tpl. Quelqu'un a une idée ? Edited March 7, 2016 by Alex--77 (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted March 7, 2016 Share Posted March 7, 2016 Il faut appeler la page (le controller) 404.php mais, magie de prestashop c'est pas codé pour rediriger mais pour juste claquer une 404. Patch comme suit: case '404': default: header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); Controller::getController('PageNotFoundController')->run(); die; $this->errors[] = Tools::displayError('This product is no longer available.'); break; 1 Link to comment Share on other sites More sharing options...
Alex--77 Posted March 7, 2016 Author Share Posted March 7, 2016 Ah merci doekia, je savais que c'était un petit bout de code à ajouter. Sans me rendre compte, j'étais prêt à recoder le controler de 404.php :wacko: Link to comment Share on other sites More sharing options...
Jean André Posted November 27, 2019 Share Posted November 27, 2019 (edited) Merci Doekia, j'ai utilisé ton patch cela fonctionne pour moi aussi sur une version 1.6.1.18 Pour compléter le sujet le fichier productcontroller.php se trouve dans controllers/front/ Edited November 27, 2019 by Jean André (see edit history) Link to comment Share on other sites More sharing options...
Nagrad Posted March 28, 2020 Share Posted March 28, 2020 Bonjour, Savez-vous comment rédiger une page 404 vers la page d’accueil sous PS1.6 ? Merci ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now