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!
Commentaires (5)
Trackbacks (0)
(Souscrire aux commentaires de cet article)
Aucun trackbacks pour l'instant

1 février 2010
ohhhhhhhhhhh
superbe merci Pierre yves
26 mars 2010
Bonjour Pierre,
je reviens vers vous concernant cette modif.
Je souhaiterais ajouter le prix pour produit dans le title
j’ai essayé ceci
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}
mais la variable ne passe pas
donc j’ai essayé ceci aussi
$prod = new Product( intval($id_product) );
$manu = new Manufacturer( $prod->id_manufacturer );
$manu2 = convertPrice price($product->getPrice);
$row['meta_title'] = ($row['meta_title'] != » ? $row['meta_title'] . ‘ – ‘ . $manu->name : $row['name'] . ‘ – ‘ . $manu->name). ‘ – ‘ .$manu2->convertPrice price) ;
mais bien sur cela ne marche pas
si eventuellment vous pouvez m’aider je vous remercierais
30 mars 2010
Bonjour,
je pensais que vous pouviez m’aider
Ça ne fait rien
a +
23 juin 2010
Très interressant.
Merci
23 juin 2010
Je cherche à inserer le nom de la catégorie. Pouvez-vous m’aider ?
Merci