Skip to content

Conversation

@acidvertigo
Copy link
Contributor

...ns in general.php

@acidvertigo
Copy link
Contributor Author

I'm tryng to change the tep_count_products_in_category to this:

 function tep_count_products_in_category($include_inactive = false) {
     if ($include_inactive == true) {
       $products_query = tep_db_query("SELECT c.categories_id,count(p.products_id) AS total from " . TABLE_PRODUCTS . " p left join  " . TABLE_PRODUCTS_TO_CATEGORIES . " c on  p.products_id = c.products_id GROUP BY c.categories_id");
       } else {
       $products_query = tep_db_query("SELECT c.categories_id,count(p.products_id) AS total from " . TABLE_PRODUCTS . " p left join  " . TABLE_PRODUCTS_TO_CATEGORIES . " c on  p.products_id = c.products_id WHERE products_status = '1' GROUP BY c.categories_id");
        }
    while($p_count = tep_db_fetch_array($products_query)) {
     $products_count[$p_count['categories_id']] = $p_count;
    } 
    return $products_count;
  }  

to return in one query all categories id with total of the products, but unfortunately the query does not shows categories with 0 products... if someone can help....

@acidvertigo
Copy link
Contributor Author

I've found that is easier to check only if the current category has products and then not count also subcategories when calling the function from index.php

@acidvertigo acidvertigo reopened this Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant