Récemment


[1.5.x],[1.6.x],[1.7.x] Pas de redirection canonical pour page manufacturer & supplier



  • Lorsque vous effectuez une redirection /index.php?controller=manufactuer|supplier (sans id), aucune redirection canonique n'est prise en compte.

    Ex:
    https://domain.tld/marques => mène à la liste des manufacturer (marques)
    https://domain.tld/index.php?controller=manufacturer => mène à la liste des manufacturer (marques)

    Aucun redirection canonique n'intervient dans le second cas
    0_1542402459601_SEO&URL - Modifier   manufacturer.png

    Seul le cas lorsqu'un id est fourni est implanté dans les contrôleurs.
    Remplacer dans ManufacturerController.php:

        public function canonicalRedirection($canonicalURL = '')
        {
            if (Tools::getValue('live_edit')) {
                return;
            }
            if (Validate::isLoadedObject($this->manufacturer)) {
                parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
            }
        }
    

    par

        public function canonicalRedirection($canonicalURL = '')
        {
            if (Tools::getValue('live_edit')) {
                return;
            }
            if (!Validate::isLoadedObject($this->manufacturer) && (int)Tools::getValue('id_manufacturer')) {
                $this->manufacturer = new Manufacturer((int)Tools::getValue('id_manufacturer'), $this->context->language->id);
            }
            if (Validate::isLoadedObject($this->manufacturer)) {
                return parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
            }
            parent::canonicalRedirection($canonicalURL);
        }
    


  • Comme ces 2 là font toujours la paire, la même ligne est à ajouter dans SupplierController.php ;)

        public function canonicalRedirection($canonicalURL = '')
        {
            if (Tools::getValue('live_edit')) {
                return;
            }
            if (!Validate::isLoadedObject($this->supplierr) && (int)Tools::getValue('id_supplier')) {
                $this->supplier = new Supplier((int)Tools::getValue('id_supplier'), $this->context->language->id);
            }
            if (Validate::isLoadedObject($this->supplier)) {
                parent::canonicalRedirection($this->context->link->getSupplierLink($this->supplier));
            }
            parent::canonicalRedirection($canonicalURL);
        }
    


  • @eolia au temps pour moi je pensais que le titre était suffisamment clair (manufacturer et supplier)



  • @doekia

    Attention il y a eu une grosse coquille dans le code publié plus tôt.
    Il est maintenant corrigé mais pensez à le vérifier si vous avez appliqué le patch précédemment