2013-09-24 107 views
0

我正在使用opencart 1.5.4。Opencart顯示兒童類別列表中的總產品數量

我想了解有多少產品是在孩子類別我這個頁面上的類別列表中的計數:

http://50.87.186.42/index.php?route=product/category&path=59_60 

我嘗試添加的代碼,但它看起來像它已經是在控制器(類別/控制器/模塊/ category.php)

這裏是我看代碼:

 foreach ($children as $child) { 
      $data = array(
       'filter_category_id' => $child['category_id'], 
       'filter_sub_category' => true 
      ); 

      $product_total = $this->model_catalog_product->getTotalProducts($data); 

      $total += $product_total; 

      $children_data[] = array(
       'category_id' => $child['category_id'], 
       'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''), 
       'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) 
      );  
     } 

它看起來就像是使用以下$全部或$ product_total但我t不顯示在前端。我是否在某個地方關閉了它,或者有辦法重新啓用它?

感謝,

馬特

回答

0

repalce本的foreach(孩子全$類未$),並讓我知道,如果它的工作或不...

 foreach ($categories as $category) { 
     $total = $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $category['category_id'])); 

     $children_data = array(); 

     $children = $this->model_catalog_category->getCategories($category['category_id']); 

     foreach ($children as $child) { 



      $product_total = $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $child['category_id'])); 

      $total += $product_total; 

      $children_data[] = array(
       'category_id' => $child['category_id'], 
       'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''), 
       'total' => $product_total, 
       'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) 
      );  
     } 

     $this->data['categories'][] = array(
      'category_id' => $category['category_id'], 
      'name'  => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''), 
      'children' => $children_data, 
      'href'  => $this->url->link('product/category', 'path=' . $category['category_id']) 
     ); 
    } 
相關問題