Jump to content

Total Nr of products displayed on Front page!


Recommended Posts

Hi there!

I have searched but with no sucess...
Is there a way to show my customers the total Nr of products the store has ?!
I mean, a module or something showing total product quantity...

Any help would be very welcomed :)

Btw check my sign for the site!

Rgds,
Zippout

Share this post


Link to post
Share on other sites

There is no module available that aware that will do that. The catalog statistics module in the Back Office counts the total number of products, but I don't think you can use that in the Front Office. I can write a query for you that will get the total number of products. Put the following code before the $smarty->display that calls the TPL file you want the total in:

$result = Db::getInstance()->getRow('
       SELECT COUNT(DISTINCT p.`id_product`) AS total
       FROM `'._DB_PREFIX_.'product` p
       WHERE p.`active` = 1');
$smarty->assign('total', $total);



Then you can use {$total} wherever you want the total number of products displayed.

  • Like 1

Share this post


Link to post
Share on other sites
  • 1 year later...
There is no module available that aware that will do that. The catalog statistics module in the Back Office counts the total number of products, but I don't think you can use that in the Front Office. I can write a query for you that will get the total number of products. Put the following code before the $smarty->display that calls the TPL file you want the total in:

$result = Db::getInstance()->getRow('
       SELECT COUNT(DISTINCT p.`id_product`) AS total
       FROM `'._DB_PREFIX_.'product` p
       WHERE p.`active` = 1');
$smarty->assign('total', $total);



Then you can use {$total} wherever you want the total number of products displayed.




Hi there,

I just wanted to add a small modification to the code:

$result = Db::getInstance()->getRow('
       SELECT COUNT(DISTINCT p.`id_product`) AS total
       FROM `'._DB_PREFIX_.'product` p
       WHERE p.`active` = 1');
$smarty->assign('total', $result['total']);



Tested on Prestashop 1.3.5 and it works perfectly.

Cheers,
Laci

  • Like 1

Share this post


Link to post
Share on other sites
  • 3 years later...

Hi!

 

I am having trouble with adding this to my PrestaShop (v1.6.0.8). I wanted to add displaying total nr of products in the tags menu. I've added 

$result = Db::getInstance()->getRow(' SELECT COUNT(DISTINCT p.`id_product`) AS total FROM `'._DB_PREFIX_.'product` p WHERE p.`active` = 1');$this->smarty->assign('total', $total);

 to the blocktags.php file right before  "return $this->display(__FILE__, 'blocktags.tpl');" and then tried to display it with "In store: <?php echo $total;?>. " in the blocktags.tpl file. Now on my homepage i can only see "In store: ."

 

Can anyone help?
 

Edited by Szkudi (see edit history)

Share this post


Link to post
Share on other sites

Hi!

 

I am having trouble with adding this to my PrestaShop (v1.6.0.8). I wanted to add displaying total nr of products in the tags menu. I've added 

 to the blocktags.php file right before  "return $this->display(__FILE__, 'blocktags.tpl');" and then tried to display it with "In store: <?php echo $total;?>. " in the blocktags.tpl file. Now on my homepage i can only see "In store: ."

 

Can anyone help?

 

 

Add this before return $this->display-> blocktags.tpl (as u said)

 

 $result = Db::getInstance()->getRow('        SELECT COUNT(DISTINCT p.`id_product`) AS total        FROM `'._DB_PREFIX_.'product` p        WHERE p.`active` = 1');
  $this->smarty->assign('total', $result['total']);
 
And in TPL file write {$total} and it works.

Share this post


Link to post
Share on other sites

There is a free module out there for Prestashop 1.4 and 1.5. I can update for 1.6 if adequate thumbs up appear.

 

Download now: http://www.megventure.com/index.php?controller=attachment&id_attachment=12

 

 

Hi there,

 

Your module is exactly what I need ;) I have a question though: How can I add polish character set (ISO-8859-2) so polish text could be displayed properly?

Share this post


Link to post
Share on other sites
  • 5 months later...

Hi all,

 

Block Product Count Module has been upgraded. It is still free and now compatible with Prestashop 1.6.

 

You can find the download link here: http://www.prestashop.com/forums/topic/285905-free-module-block-product-count/?p=1441184

 

Cheers!

 

P.S. the best way of thank you is to leave a testimonial or a review on our website.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

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