2.14.3.20. Disable product count in OpenCart categories

Default OpenCart functionality that counts products in categories is too resource-intensive and can cause huge page processing delays and high server load. It is recommended to disable it for sites. Disable procedure depends on the OpenCart version in use:

  1. Open the site admin panel.
  2. Go to "System → Settings":
  3. To the right of the store name, click "Edit":
  4. On the "Options" tab, next to "Products per category", select "No":
  5. Save changes by clicking "Save" in the upper-right corner of the page:
  6. Check the site operation.
If you use OpenCart version 1.5.1 or lower, you must disable the count function directly in site code. To do this, follow these steps:
  1. Edit the catalog/controller/common/header.php file:
    1. At approximately line 200, find the following line and comment it out by adding // at the beginning:
      $product_total = $this->model_catalog_product->getTotalProducts($data);
    2. Find the line:
      'name'  => $child['name'] . ' (' . $product_total . ')',

      And replace it with this:

      'name'  => $child['name'],
    3. In the end, you should get the following:
      //$product_total = $this->model_catalog_product->getTotalProducts($data);
      $children_data[] = array</b></br>
      'name'  => $child['name'],</b></br>
      'href'  => 'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . </b>  </br>
      );
  2. Check the site operation.
Content