Manu-41 Posted July 31, 2021 Share Posted July 31, 2021 (edited) Bonjour, je voudrais afficher les sœurs de la catégorie par défaut de mon produit sur la page produit. Pourriez-vous me dire comment m'y prendre ? J'ai testé avec ça, mais ça ne renvoi rien <ul> {foreach Category::getChildren($product->id_category_default, 1) as $category} <li><a href="{$link->getCategoryLink($category.id_category)}">{$category.name}</a></li> {/foreach} </ul> Merci pour votre aide. Je suis sous ps 1.6 Edited August 2, 2021 by Manu-shop (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted July 31, 2021 Share Posted July 31, 2021 Vous dites chercher les soeurs mais votre code cherche les enfants (filles) Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 Just now, doekia said: Vous dites chercher les soeurs mais votre code cherche les enfants (filles) Oui, d'où ma demande. Je ne trouve pas comment afficher les sœurs, une info ? Merci pour votre aide précieuse Link to comment Share on other sites More sharing options...
doekia Posted July 31, 2021 Share Posted July 31, 2021 Non testé {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_default_category} ORDER BY c2.nleft {/capture} <ul> {foreach Db::getInstance()->executeS($smarty.capture.sql) as $category_siblings} {if $category_siblings.id_category != $product->id_default_category} <li> .... </li> {/if} {/foreach} </ul> Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 10 minutes ago, doekia said: {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_default_category} ORDER BY c2.nleft {/capture} Pour un fichier php, product.php? Link to comment Share on other sites More sharing options...
doekia Posted July 31, 2021 Share Posted July 31, 2021 ? qui parle de php ? Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 3 minutes ago, doekia said: ? qui parle de php ? C’est 2 code différent , non ? Ou je le place directement dans un TPL? merci pour ces précisions. Link to comment Share on other sites More sharing options...
doekia Posted July 31, 2021 Share Posted July 31, 2021 oui dans le tpl Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 Je viens de tester, dans le product.tpl, rien ne s'affiche Link to comment Share on other sites More sharing options...
doekia Posted July 31, 2021 Share Posted July 31, 2021 {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_category_default|intval} ORDER BY c2.nleft {/capture} <ul> {foreach Db::getInstance()->executeS($smarty.capture.sql) as $category_siblings} {if $category_siblings.id_category != $product->id_category_default} <li> .... </li> {/if} {/foreach} </ul> Testé et fonctionelle Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 14 minutes ago, doekia said: {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_category_default|intval} ORDER BY c2.nleft {/capture} <ul> {foreach Db::getInstance()->executeS($smarty.capture.sql) as $category_siblings} {if $category_siblings.id_category != $product->id_category_default} <li> .... </li> {/if} {/foreach} </ul> Testé et fonctionelle Y a du mieux, ça m'affiche uniquement les ... les li dans les product.tpl Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 (edited) j'ai testé avec ceci, mais ca ne fonctionne pas. Edited July 31, 2021 by Manu-shop (see edit history) Link to comment Share on other sites More sharing options...
Manu-41 Posted July 31, 2021 Author Share Posted July 31, 2021 (edited) 5 hours ago, doekia said: {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_category_default|intval} ORDER BY c2.nleft {/capture} <ul> {foreach Db::getInstance()->executeS($smarty.capture.sql) as $category_siblings} {if $category_siblings.id_category != $product->id_category_default} <li> .... </li> {/if} {/foreach} </ul> Testé et fonctionelle Ca avance, les ID de catégories s'affichent bien. Comment afficher le mon de ces catégories avec l'id? {capture name="sql"} SELECT c2.id_category FROM `{$smarty.const._DB_PREFIX_}category` c INNER JOIN `{$smarty.const._DB_PREFIX_}category` c2 ON c2.id_parent = c.id_parent WHERE c.id_category = {$product->id_category_default|intval} ORDER BY c2.nleft {/capture} <ul> {foreach Db::getInstance()->executeS($smarty.capture.sql) as $category_siblings} {if $category_siblings.id_category != $product->id_category_default} <li> <a href="{$link->getCategoryLink($category_siblings.id_category)}">???</a> </li> {/if} {/foreach} </ul> Edited July 31, 2021 by Manu-shop (see edit history) Link to comment Share on other sites More sharing options...
Manu-41 Posted August 1, 2021 Author Share Posted August 1, 2021 Pour afficher le nom de la catégorie, j'ai essayé ca: <a href="{$link->getCategoryLink($category_siblings.id_category)}">{$category_siblings.id_category}{$category_siblings->name}</a> <a href="{$link->getCategoryLink($category_siblings.id_category, $category_siblings.link_rewrite)}">{$category_siblings.name}</a> Mais aucun ne fonctionne. Une idée ? Link to comment Share on other sites More sharing options...
Manu-41 Posted August 1, 2021 Author Share Posted August 1, 2021 un petit up pour votre aide Link to comment Share on other sites More sharing options...
doekia Posted August 2, 2021 Share Posted August 2, 2021 soit: ajouter une jointure sur category_lang et reprendre le champ name utiliser Category::getCategoryInformations((array)category_sibling.id_category Link to comment Share on other sites More sharing options...
Manu-41 Posted August 2, 2021 Author Share Posted August 2, 2021 1 hour ago, doekia said: soit: ajouter une jointure sur category_lang et reprendre le champ name utiliser Category::getCategoryInformations((array)category_sibling.id_category J’ai utilisé FrontController::getCategoryName Ça fonctionne. Merci encore pour ton aide 😉 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