Jump to content

[1.6.1.1] Rediriger Vers La Page 404


Recommended Posts

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 by Alex--77 (see edit history)
Link to comment
Share on other sites

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;

  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...
  • 4 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...