Jump to content

Want to use sql command and result assigned on smarty


Nasir Malik
 Share

Recommended Posts

SELECT ROUND(AVG(p.price) ,0), c.id_category FROM psup_product p INNER JOIN psup_category_product pc ON p.id_product = pc.id_product INNER JOIN psup_category_product c ON pc.id_category = c.id_category GROUP BY c.id_category

want to use this command on php and assign smarty variable to use on category.tpl to get result on every category page to show product average price

any idea?

 

my version is prestashop 1.6.1.24

Edited by Nasir Malik
space edit on sql command (see edit history)

Share this post


Link to post
Share on other sites

The assignment of Smarty variables is not that difficult.

In this case the php file involved is /controllers/front/CategoryController.php

There in the function initContent() the Smarty variables are assigned in the part that starts with $this->context->smarty->assign(array(

Add your own variable and then you can use it in category.tpl.

 

Share this post


Link to post
Share on other sites

3 minutes ago, Nasir Malik said:

Thanks for reply

i'm new on prestashop and no idea how and where i put code can you please guide where to put code and what code i put on CategoryController.php

Sorry, if you don't understand the code in this function  - even after some experimenting - I think you would do better to hire someone.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More