cactus20 Posted May 2, 2016 Share Posted May 2, 2016 (edited) Hi guys, I create a module in prestashop to show in home page. My product in prestashop have categories (chocolate, cheese, candy...) and tags (usa, uk, china, spain...), my module show a list of all tags and a second list with categories. When I click in a tag I have to show all product with this tags.... for example if I click un "usa" I have to show chocolate ---- 3items Cheese ---- 2 items Candy ---- 4 items and all this product are from usa tags By other hands when I click in categories for example "cheese" I have to create a list with Usa cheese--- 2 items Uk cheese --- 4 items Spain cheese --- 5 items What is the best way to do that? Create other module to do this functionality and show this in product-list.tpl. What is the best way to do that? Thanks in advance. Edited May 4, 2016 by cactus20 (see edit history) Link to comment Share on other sites More sharing options...
cactus20 Posted May 4, 2016 Author Share Posted May 4, 2016 Hi guys, I think that I have the solution, I am override the ProductController to add new function and call a new view too, but my question is, how create a hyperlink to this new function? thanks in advances! Link to comment Share on other sites More sharing options...
cactus20 Posted May 4, 2016 Author Share Posted May 4, 2016 Hi, tupe of hyperlink? to product page or category page? It depends on what action you want to execute. Hi ndiaga for you reply, I override my controller I have a new function call getTagsProducts but I don't know create a link in my view to call this function using getProductLink Link to comment Share on other sites More sharing options...
cactus20 Posted May 4, 2016 Author Share Posted May 4, 2016 From a module you create a link this way: 'my_link' => $this->context->link->getModuleLink('module_name', 'controller_name'), // in smarty array Sorry ndiaga, I don't understand very well you solution... I explain better.. I have a module create by myself, this module call to homeparadise.tpl view with some parameters like this $this->context->smarty->assign(array( 'products' => $products, 'categories' => $allCategories, 'tag_element' => $country_tag )); return $this->display(__FILE__, 'homeparadise.tpl'); So now I homeparadise.tpl I show the info like that {foreach from=$v item=value} {* {$product|print_r}; *} <a href="{$link->getProductLink({$product.id_product})}"> 'my_link' => $this->context->link->getModuleLink('module_name', 'controller_name'), <img src="{$img_dir}img_paradise/{$tag_element[$value]}.jpg" class="img-responsive" alt="UP3 company"/> <div class="country_name">{$tag_element[$value]|escape:html:'UTF-8'}</div> </a> {/foreach} I need to change this <a href="{$link->getProductLink({$product.id_product})}"> to call a new function that I create in Product controller How to do that in PrestaShop? Thanks in advances! Link to comment Share on other sites More sharing options...
cactus20 Posted May 4, 2016 Author Share Posted May 4, 2016 Ok so here is what you need: {foreach from=$v item=value} {* {$product|print_r}; *} <a href="index.php?id_product={$product.id_product}&controller=product&id_lang={Tools::getValue('id_lang')}"> <img src="{$img_dir}img_paradise/{$tag_element[$value]}.jpg" class="img-responsive" alt="UP3 company"/> <div class="country_name">{$tag_element[$value]|escape:html:'UTF-8'}</div> </a> {/foreach} //you don't need to create a link fot that. this is not necessary my_link' => $this->context->link->getModuleLink('module_name', 'controller_name'), Thanks Ndiaga I see, but where you call a function that it is in the Product controller public function getByTag($tag_name){ .... } 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