Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify count of products and subcategories using the dedicated functio... #207

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

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.

None yet

1 participant