title: prestashop get product information on category list
body: <p>I have many product categories in my store and some of them don't have products. I would like to erase the link on them, so the user can see them but wouldn't lose time exploring categories without products.</p>
  
  <p>However I can't manage to get the number of products in the category. I've tried this but it gives me a 403 error</p>
  
  <pre><code>$.get('/themes/theme/product.tpl', function(r){
      var obj = $(r).find('body');
      var PageText = $(r).find('.center_indent').text();
      if (PageText===""){alert("yes")}
      else {alert("no")}
  });
  </code></pre>
  
  <p>Does anyone have an idea? I'm working with prestashop 1.6.1.9</p>
  
  <p>Edit: I found out I couldn't make an array of subcategories, so I added a function in the Category class:</p>
  
  <pre><code>public static function countProductInCat($id_category)
  {
      $category = new Category($id_category, 1);
      $productCount = $category-&gt;getProducts(1, 1, 10000, null, null, true);
      return $productCount;
  }
  </code></pre>
  
  <p>And I called it in the category-description.tpl file:</p>
  
  <pre><code>{if (Category::countProductInCat($subcategory_id)) &gt; 0}
        &lt;a href="{$link-&gt;getCategoryLink($subcategory.id_category,$subcategory.link_rewrite)|escape:'html':'UTF-8'}"&gt;&lt;/a&gt;                                                             
  {else}
      &lt;span style="opacity:0.3;background:#999"&gt;&lt;/span&gt;
  {/if}
  </code></pre>