Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

383
 
638
 
638
 
category_tree.php
_> 11 <?php
  22 /*
<> 3 -  $Id: category_tree.php 383 2006-01-09 16:35:46Z hpdl $
   3+  $Id: category_tree.php 638 2006-07-18 16:33:44Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
     
 !
257257     }
  258258 
  259259     function calculateCategoryProductCount() {
<>  260+      global $osC_Database;
   261+
   262+      $totals = array();
   263+
   264+      $Qtotals = $osC_Database->query('select p2c.categories_id, count(*) as total from :table_products p, :table_products_to_categories p2c where p2c.products_id = p.products_id and p.products_status = :products_status group by p2c.categories_id');
   265+      $Qtotals->bindTable(':table_products', TABLE_PRODUCTS);
   266+      $Qtotals->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
   267+      $Qtotals->bindInt(':products_status', 1);
   268+      $Qtotals->execute();
   269+
   270+      while ($Qtotals->next()) {
   271+        $totals[$Qtotals->valueInt('categories_id')] = $Qtotals->valueInt('total');
   272+      }
   273+
   274+      $Qtotals->freeResult();
   275+
260276       foreach ($this->data as $parent => $categories) {
  261277         foreach ($categories as $id => $info) {
<> 262 -          $this->data[$parent][$id]['count'] = $this->countCategoryProducts($id);
   278+          if ($totals[$id] > 0) {
   279+            $this->data[$parent][$id]['count'] = $totals[$id];
263280 
<> 264 -          $parent_category = $parent;
  265 -          while ($parent_category != $this->root_category_id) {
  266 -            foreach ($this->data as $parent_parent => $parent_categories) {
  267 -              foreach ($parent_categories as $parent_category_id => $parent_category_info) {
  268 -                if ($parent_category_id == $parent_category) {
  269 -                  $this->data[$parent_parent][$parent_category_id]['count'] += $this->data[$parent][$id]['count'];
   281+            $parent_category = $parent;
   282+            while ($parent_category != $this->root_category_id) {
   283+              foreach ($this->data as $parent_parent => $parent_categories) {
   284+                foreach ($parent_categories as $parent_category_id => $parent_category_info) {
   285+                  if ($parent_category_id == $parent_category) {
   286+                    $this->data[$parent_parent][$parent_category_id]['count'] += $this->data[$parent][$id]['count'];
270287 
<> 271 -                  $parent_category = $parent_parent;
  272 -                  break 2;
   288+                    $parent_category = $parent_parent;
   289+                    break 2;
   290+                  }
273291                 }
  274292               }
  275293             }
  276294           }
  277295         }
  278296       }
<> 279 -    }
280297 
<> 281 -    function countCategoryProducts($category_id) {
  282 -      global $osC_Database;
  283 -
  284 -      $Qcategories = $osC_Database->query('select count(*) as total from :table_products p, :table_products_to_categories p2c where p2c.categories_id = :categories_id and p2c.products_id = p.products_id and p.products_status = 1');
  285 -      $Qcategories->bindRaw(':table_products', TABLE_PRODUCTS);
  286 -      $Qcategories->bindRaw(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
  287 -      $Qcategories->bindInt(':categories_id', $category_id);
  288 -      $Qcategories->execute();
  289 -
  290 -      $count = $Qcategories->valueInt('total');
  291 -
  292 -      $Qcategories->freeResult();
  293 -
  294 -      return $count;
   298+      unset($totals);
<_ 295299     }
  296300 
  297301     function setRootCategoryID($root_category_id) {