MultiMeun Posted August 9, 2018 Share Posted August 9, 2018 (edited) Hi, I'm new to Prestashop and struggling since a couple of days with a basic task... I just would like to list the products of each category into my header (header.tpl). I don't know how to do it. I know how to list products : {if $listing.products|count} {block name='product_list'} {include file='catalog/_partials/products.tpl' listing=$listing} {/block} {else} {include file='errors/not-found.tpl'} {/if} But I don't know how to set up a category to this listing. Please can you help me ? Thanks a lot ! NB. I'm using Prestashop 1.7.4 Edited August 10, 2018 by MultiMeun (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted August 12, 2018 Share Posted August 12, 2018 You need to assign the variable from the controller first, it's not available in the header by default. Have a look at initContent in the FrontController class. Get all categories, then all products for them, and assign to the template. This way the list will be available in all pages Link to comment Share on other sites More sharing options...
MultiMeun Posted August 20, 2018 Author Share Posted August 20, 2018 On 12/08/2018 at 2:30 AM, NemoPS said: You need to assign the variable from the controller first, it's not available in the header by default. Have a look at initContent in the FrontController class. Get all categories, then all products for them, and assign to the template. This way the list will be available in all pages First of all, thank you very much for your answer. Despite my inexperience to Prestashop, I tried to go ahead on your track. - I've created a 'buildmenu' module (/modules/buildmenu/) - A 'custom.php' file into '/modules/buildmenu/controllers/front/' - A 'buildmenu.tpl' file into '/modules/buildmenu/views/templates/front/' Here is the code in my 'custom.php' file : <?php class BuildMenu extends ModuleFrontController { public function initContent() { $this->context->smarty->assign(array( 'hello' => 'Hello World!!!', )); $this->setTemplate('buildmenu.tpl'); } } ?> Now I don't know : - how to get all categories and all products - how to display it on my main template (/themes/mytheme/templates/_partials/header.tpl) Thank you ! 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