Norben Posted November 9, 2020 Share Posted November 9, 2020 Hello, If a product belongs to several categories, could you tell me how to display these category names in a product page (Prestashop 1.7.6.8) (that the name of the category of the last level) in the form of "link" And if it is possible exclude this display on 1 categories. ...to display in my product pages which categories this product belongs to. To have a final result as follows in front affice :This product belongs to the following categories : xxxxxxx, xxxxxxxx, xxxxxxxxxx, xxxxxxxxxx, xxxxxxxxx, Thank you for your help. Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 Hi, Thank you fo your reply, It work but it show all categorie path and there is no link. I want to display only name of the last level of my categories. Thank you for your help Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 i tried this : <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/foreach} </ul> In this example i have the link for my categorie but it show full category path if possible to show only the last level Thank you Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 Hi Tengler, I realy apriciate your help, it's number : 4 In this example my main category is number 2 and I want to display only number 4. Thank you Tengler, Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest updated function (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted November 9, 2020 Share Posted November 9, 2020 Bonjour, Merci de parler en français dans la section française du forum ou de poster dans la section correspondante à votre langue. 1 Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted November 9, 2020 Share Posted November 9, 2020 à l’instant, Guest a dit : Je réponds dans la langue dans laquelle le sujet a été fondé. Ce n'est pas un problème pour moi d'utiliser un traducteur. Signalez le sujet au modérateur et demandez-lui de passer sur le forum anglais 😉 Merci Le signalement fut fait depuis plus de 12 h et vous même auriez pu faire ce signalement puisque vous maitrisez très bien le forum. Les sections existe pour une bonne raison alors merci de respecter la structure du forum pour lui conserver une certaine cohérence. Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2020 Share Posted November 9, 2020 👍 Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 Bonjour Tengler, Merci pour votre aide. Je vais essayer demain et je donnerais des nouvelles. Apparement j'ai poster un topic dans la mauvaise rubrique concernant la langue, je ne savais pas qu'il y'avait Merci encore une fois. Hello Tengler, Thanks for your help. I will try tomorrow and give updates. Apparently I posted a topic in the wrong section concerning the language, Thanks again. Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 Bonjour, j'ai essayé la solution que vous m'avez proposer mais j'ai une erreur 500 ☹️ Hi, I tried the solution, but I have a 500 error Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 I think it's good we are in the right place "English" Link to comment Share on other sites More sharing options...
Norben Posted November 9, 2020 Author Share Posted November 9, 2020 Hi, Only this one work perfect for me, <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} {if $cat.id_category!=2} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/if} {/foreach} </ul> But it show all category path, I need to know if I can do some changes to display only the last level Thank you. Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 10, 2020 Author Share Posted November 10, 2020 Hi Tengler, After doing this manipulation I have no access to my website, I restored my backup 😓 As I told you in my previous message, it's the only code that works (it's not yours) but it show all category path, I need to know if I can do some changes to display only the last level <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} {if $cat.id_category!=2} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/if} {/foreach} </ul> Thank you. Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Verlonimo Posted November 10, 2020 Share Posted November 10, 2020 (edited) 4 hours ago, Norben said: Hi Tengler, After doing this manipulation I have no access to my website, I restored my backup 😓 As I told you in my previous message, it's the only code that works (it's not yours) but it show all category path, I need to know if I can do some changes to display only the last level <ul class="productcats"> {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat} {if $cat.id_category!=2} <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li> {/if} {/foreach} </ul> Thank you. Hi, Not sure what exactly you want but You might want try to use smarty last iteration. So instead of {if $cat.id_category!=2} Try {if $cat.last} It should display only last item from foreach. Thanks Edited November 10, 2020 by Verlonimo (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 10, 2020 Share Posted November 10, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 10, 2020 Author Share Posted November 10, 2020 Hi Verlimino, if a product is associated with several categories I want to display in the product page these category names to which this product belongs, the code I posted works but it shows me the whole tree of categories, I want to display only the the list of last levels category Link to comment Share on other sites More sharing options...
Norben Posted November 10, 2020 Author Share Posted November 10, 2020 It’s exactly what i want to display in my product page, Link to comment Share on other sites More sharing options...
Verlonimo Posted November 10, 2020 Share Posted November 10, 2020 I am on mobile right now so cant help much... But instead of using Product::getProductCategoriesFull Try to use Product::getProductCategories This should display only categories related to product. Thanks Link to comment Share on other sites More sharing options...
Guest Posted November 11, 2020 Share Posted November 11, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 11, 2020 Share Posted November 11, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 11, 2020 Share Posted November 11, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 12, 2020 Author Share Posted November 12, 2020 Hi Tengler, Sorry for the delay, It's exactly what i need can i choose the depth of the category (or level) in your solution? Thank you Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2020 Share Posted November 12, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 12, 2020 Author Share Posted November 12, 2020 Hi Tengler, I have approximatly 30.000 sub-categories 😓 with depth 3 to displayed and approximatly 10 categories to exclude Can I select for example depth 3 for all and exclude some categorie manualy ? Thank you Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2020 Share Posted November 12, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2020 Share Posted November 12, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 12, 2020 Author Share Posted November 12, 2020 Hi Tengler, Sorry for my English, next time i will use google translate, I don't have one product for 30.000 categories I sell cartridge and i want to display compatibility in product page Thank you, Link to comment Share on other sites More sharing options...
Guest Posted November 13, 2020 Share Posted November 13, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 13, 2020 Author Share Posted November 13, 2020 Hi Tengler, I don't have feed from supplier, I have already asked the question to my supplier Link to comment Share on other sites More sharing options...
Guest Posted November 18, 2020 Share Posted November 18, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 19, 2020 Author Share Posted November 19, 2020 Hi Tengler, I found a solution but I'm ready to buy your module. Tell me when it will be ready. Regards. Link to comment Share on other sites More sharing options...
Guest Posted November 19, 2020 Share Posted November 19, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted November 19, 2020 Share Posted November 19, 2020 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Norben Posted November 29, 2020 Author Share Posted November 29, 2020 Hi Tengler, I can't find the module in your store. Thanks you Link to comment Share on other sites More sharing options...
hhcj Posted September 20, 2021 Share Posted September 20, 2021 This works in prestashop 1.7.7.5 in product tpl <ul class="productcats"> {foreach from=Product::getProductCategories($product.id) item=cat} {if $cat > 2} {assign var='current_cat' value=Category::getCategoryInformations(array($cat))} <li><a href="{$link->getCategoryLink({$cat})}" title="{$current_cat[{$cat}]['name']}">{$current_cat[{$cat}]['name']}</a></li> {/if} {/foreach} </ul> 1 Link to comment Share on other sites More sharing options...
Abu Joury Posted September 4, 2023 Share Posted September 4, 2023 (edited) On 9/20/2021 at 12:57 PM, hhcj said: This works in prestashop 1.7.7.5 in product tpl <ul class="productcats"> {foreach from=Product::getProductCategories($product.id) item=cat} {if $cat > 2} {assign var='current_cat' value=Category::getCategoryInformations(array($cat))} <li><a href="{$link->getCategoryLink({$cat})}" title="{$current_cat[{$cat}]['name']}">{$current_cat[{$cat}]['name']}</a></li> {/if} {/foreach} </ul> This has worked for me: It's Category::getCategoryInformation(array($cat))} not "getCategoryInformations(...)" <ul class="productcats">{foreach from=Product::getProductCategories($product.id) item=cat}{if $cat > 2}{assign var='current_cat' value=Category::getCategoryInformation(array($cat))}<li><a href="{$link->getCategoryLink({$cat})}" title="{$current_cat[{$cat}]['name']}">{$current_cat[{$cat}]['name']}</a></li>{/if}{/foreach}</ul> Edited September 4, 2023 by Abu Joury (see edit history) 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