msevestre Posted December 21, 2011 Share Posted December 21, 2011 Bonjour je souhaite ajouter dans al liste des produits le nom de la catégorie devant le nom produit. j'ai réussi à y coller d'ID catégorie, mais impossible d'en extraire le nom. Comment faire ? Merci Matt Link to comment Share on other sites More sharing options...
luci1 Posted December 21, 2011 Share Posted December 21, 2011 Bonjour, Dans le fichier template product-list.tpl qui est appelé quand tu affiches une catégorie, tu peux accéder au nom de la catégorie avec {$category->name|escape:'htmlall':'UTF-8'} Link to comment Share on other sites More sharing options...
msevestre Posted December 21, 2011 Author Share Posted December 21, 2011 Bonjour Merci pour ces informations. Est-ce que cela fonctionnera aussi bien en cas de recherche sur les produits ? Matt Link to comment Share on other sites More sharing options...
luci1 Posted December 21, 2011 Share Posted December 21, 2011 Non, pour les recherches de produits, ça ne fonctionnera pas. Pour que ce soit le cas, il faudrait surcharger la fonction find de la classe Search.php pour ajouter le nom de la catégorie. Link to comment Share on other sites More sharing options...
msevestre Posted December 21, 2011 Author Share Posted December 21, 2011 Hello Merci encore pour cette information Si quelqu'un a le code source à modifier ça m'arrangerait bien Mathieu Link to comment Share on other sites More sharing options...
msevestre Posted December 22, 2011 Author Share Posted December 22, 2011 Bonjour j'ai finalement avancé en créant une fonction getNameById dans la un fichier d'override de Category.php. Ainsi dans product-list.tpl, je peux afficher le nom de ma catégorie par le code {Category::getNameById($product.id_category_default)} Mon fichier /override/classes/Category.php: <?php class Category extends CategoryCore { public function getNameById($id_categorie, $id_lang=NULL) { if (!(int)$id_lang) $id_lang = _USER_ID_LANG_; return Db::getInstance()->getValue(' SELECT name FROM `'._DB_PREFIX_.'category_lang` WHERE `id_lang` = '.(int)($id_lang).' AND `id_category` = '.(int)($id_categorie)); } } Matt Link to comment Share on other sites More sharing options...
Hardwell Posted September 15, 2013 Share Posted September 15, 2013 Bonjour, pour ma part la solution ne fonctionne pas, je suis sous presta 1.5.2 et toi ? Link to comment Share on other sites More sharing options...
Hardwell Posted September 21, 2013 Share Posted September 21, 2013 Help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now