Jump to content

Displaying Product Count in Category Links


Recommended Posts

Can anyone advise how we can simply add the product count in the sidebar category links?

 

I know there has been plenty of discussion on this in the forum previously but...

 

a ) don't try and sell me a different module that does this, it should be an option for the default Prestashop categories module!

 

b ) all the other tutorials don't work for Prestashop 1.4.6.2 that we're using (the code they instruct to change, isn't even found in the files) - plus, the person who made a free module for this, the SSL is broken on their website so it's impossible to even checkout with anything.

 

Any help, greatly appreciated.

 

It's frustrating that the core for Prestashop has overlooked some of the most basic fundamentals in ecommerce and the answer is to package them up in additional modules at a cost...

Share this post


Link to post
Share on other sites
  • 2 weeks later...
  • 3 weeks later...

try the module in the attachment if this is what you need.

thanks so much, but i get an error:

Notice: Undefined index: product_count in C:\wamp\www\prestashop\modules\blockcategories\blockcategories.php on line 151

 

 

please help me, how can i fix it.

thanks,

Share this post


Link to post
Share on other sites
  • 8 months later...
  • 1 month later...

Para solucionar el problema de que la variable no está declarada es necesario añadir las mismas condiciones en la function hookFooter

 

To solve the problem that the variable is not declared is necessary to add the same conditions on the function hookFooter

 

  $resultParents = array();
  $resultIds = array();


  foreach ($result as &$row)
  {
   if($row['id_category'] != 1)
   {
 $result_product_count = Db::getInstance()->ExecuteS('
 SELECT COUNT(ac.`id_product`) as totalProducts
 FROM `'._DB_PREFIX_.'category_product` ac
 LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ac.`id_product`
 WHERE ac.`id_category` = '.$row['id_category'].' AND p.`active` = 1');
 $row['product_count'] = $result_product_count[0]['totalProducts'];
   }
   $resultParents[$row['id_parent']][] = &$row;
   $resultIds[$row['id_category']] = &$row;
  }

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
×
×
  • Create New...

Important Information

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