Jump to content

postProcess() ne fonctionne pas


Shaimy

Recommended Posts

Bonjour,

J'ai créé un module avec un controller qui a pour but de rediriger un produit lorsqu'on change l'ID du produit dans URL. Mais ca ne fonctionne pas

Exemple : Si je change l'id de ce lien (ID 860), l'id de la déclinaison ne se met pas.

https://www.moondreamwebstore.fr/rideau-occultant/raye-anglet-rouge-grenat-mc330-moondream-artiga-860-3733.html ===>https://www.moondreamwebstore.fr/rideau-occultant-uni/rideau-occultant-uni-beige-coquille-mc634-15-.html

Voici le code :

public function postProcess()
    {
        if ($url = Tools::getValue('url')) {
            $str = explode('-', $url);
            $id = $str[1];
            $prod = new Product($id, true, $this->context->language->id);
            if (!Validate::isLoadedObject($prod)) {
                Tools::redirect('index.php?controller=404');
            }
            header("HTTP/1.1 301 Moved Permanently");
            Tools::redirect($this->context->link->getProductLink($prod, $prod->link_rewrite, htmlspecialchars(strip_tags($prod->category)), null, null, null, $prod->getDefaultIdProductAttribute()));
        }
    }

 

Merci pour votre aide

Edited by Shaimy (see edit history)
Link to comment
Share on other sites

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...