29jan/105
How to : Ajouter le nom du fabricant dans le META TITLE des pages produits
Bonjour,
Car la question m'est demandées plusieurs fois, j'ai donc décidé de créer un billet avec la réponse (quoi de plus logique...).
Voici donc la solution pour afficher le nom du fabricant dans le meta-title des pages produits.
1. Ouvrez le fichier « classes/Tools.php » et cherchez le code suivant :
1 2 3 4 5 6 7 8 9 10 11 12 13 | if ($id_product = Tools::getValue('id_product')) { $row = Db::getInstance()->getRow(' SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short` FROM `'._DB_PREFIX_.'product_lang` WHERE id_lang = '.intval($id_lang).' AND id_product = '.intval($id_product)); if ($row) { if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description_short']); return self::completeMetaTags($row, $row['name']); } } |
2. Replacez le par celui-ci et le tour est joué
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if ($id_product = Tools::getValue('id_product')) { $row = Db::getInstance()->getRow(' SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short` FROM `'._DB_PREFIX_.'product_lang` WHERE id_lang = '.intval($id_lang).' AND id_product = '.intval($id_product)); if ($row) { $prod = new Product( intval($id_product) ); $manu = new Manufacturer( $prod->id_manufacturer ); $row['meta_title'] = ($row['meta_title'] != '' ? $row['meta_title'] . ' - ' . $manu->name : $row['name'] . ' - ' . $manu->name); if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description_short']); return self::completeMetaTags($row, $row['name']); } } |
Voilà
Bon développement!