tobbecokta Posted January 12, 2014 Share Posted January 12, 2014 (edited) Hi, I would like to display the total amounts of sold products in the store since the store was installed. Does anyone have an idea of how to do that? Edited January 12, 2014 by tobbecokta (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 12, 2014 Share Posted January 12, 2014 the question is: where you want to display it? if in back office, go to stats, you can generate this kind of "stats" there. Link to comment Share on other sites More sharing options...
tobbecokta Posted January 12, 2014 Author Share Posted January 12, 2014 Hi! I would like to display it in the header. I know i can genereate it fron the BO, but i haven't been able to figure out how to do that for the FO... Link to comment Share on other sites More sharing options...
vekia Posted January 12, 2014 Share Posted January 12, 2014 you can do it with custom development only, module, or modification of front controller where you can include code to get sum of all orders public static function sales(){ $sql = 'SELECT COUNT(o.`id_order`) as orderCount, SUM(o.`total_paid_real` / o.conversion_rate) as orderSum FROM `'._DB_PREFIX_.'orders` o WHERE o.valid = 1'; $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return $result1['orderSum']; } then use code: {FrontController::sales()} Link to comment Share on other sites More sharing options...
tobbecokta Posted January 12, 2014 Author Share Posted January 12, 2014 Vekia you are really fast to reply, thank you for your help! However, it turns out that i wasn't so clear when i wrote what i was looking for.. I would like to display the total number of products sold, not the amount. Sorry, my misstake. Do you think you can help me modify your code (that works great by the way) so that it instead displays the total units sold? Link to comment Share on other sites More sharing options...
vekia Posted January 12, 2014 Share Posted January 12, 2014 ok i modified it: public static function sales(){ $sql = 'SELECT SUM(od.product_quantity) as products FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order` WHERE o.valid = 1 '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o'); $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return $result1['products']; } Link to comment Share on other sites More sharing options...
tobbecokta Posted January 12, 2014 Author Share Posted January 12, 2014 ok i modified it: public static function sales(){ $sql = 'SELECT SUM(od.product_quantity) as products FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order` WHERE o.valid = 1 '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o'); $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return $result1['products']; } Works like a charm, thanks for your help! Link to comment Share on other sites More sharing options...
vekia Posted January 12, 2014 Share Posted January 12, 2014 you're welcome i marked whole topic as solved with regards Milos Link to comment Share on other sites More sharing options...
Poppy381 Posted December 31, 2014 Share Posted December 31, 2014 Hi and thank you for your help. I have a little question. I have copy the code in my php module. I want to use the orderSum in my Tpl (hooked). You mentionned the {FrontController::sales()} but when I write that between a <div> on my tpl, it doesnt work and my sheet is white. How to use this Sumorder in my tpl ? Thank you for your help 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