Shellanza Posted July 4, 2016 Share Posted July 4, 2016 Hi there! I'm getting little crazy because I want to run a SQL in a controller and show the result in the frontend when all itema are listed (product-list.tpl). I did something in ProductController.php (in public function initContent()) and I assigned the output with SMARTY and on product.tpl everything is fine But I cannot understand where I have to assign the smarty variable to let the product-list.tpl give me some output There is no Controllers loading the product-list.tpl with a setTemplate. That's CRAZY :-) Please help, I'm soooo stucked :-s Thanks! Link to comment Share on other sites More sharing options...
roja45 Posted July 4, 2016 Share Posted July 4, 2016 depends where in the front end, index, i.e. featured products etc it will be the module getting the products from the category and calling the product-list.tpl directly, it gets included directly from another template, from the category pages it uses the CategoryController. It is a little inconsistent because anything via the CategoryController calls a few hooks where you can modify the list of products returned, from the homefeatured module, and other index page product lists, it doesn't call these hooks. Link to comment Share on other sites More sharing options...
Shellanza Posted July 5, 2016 Author Share Posted July 5, 2016 Hi, thanks all for suggestion. Ndiaga I never made a HOOK. Can you suggest me where to grab some information, or tutorial? I found just one for PS 1.5, don't know if is the same. Link to comment Share on other sites More sharing options...
Shellanza Posted July 5, 2016 Author Share Posted July 5, 2016 Do you think I can set this hook in the ProductController then? Link to comment Share on other sites More sharing options...
Shellanza Posted July 5, 2016 Author Share Posted July 5, 2016 Sorry for my misunderstanding. It's clear to me where to print the hook but not clear where to define it. I need to create a new module? Link to comment Share on other sites More sharing options...
Knowband Plugins Posted July 5, 2016 Share Posted July 5, 2016 If you need to use variable only on category page then check the below sample code Go to category controller and initialize your variable in initContent() using below code $this->context->smarty->assign('your_variable','$your_value'); Now open product-list.tpl and use below code to print values. {if isset($your_value)} {$your_variable} {/if} 1 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