Disable counting products in categories in OpenCart

The standard functionality of OpenCart, which calculates products in categories, is too resource-intensive and can cause huge delays in the work of pages and high load on the server. It is recommended to disable it for sites. The disconnection procedure depends on the version of OpenCart you are using:

  1. Openup Adminpanel site.
  2. Go to section "System → Settings" ("System → Settings"):
  3. To the right of the store name, click "Edit" ("Edit"):
  4. In the tab "Options" ("Options") against "Number of products in a category" choose "No":
  5. Save changes by clicking "Save" ("Save") in the upper right corner of the page:
  6. Check the site is working.
If you are using OpenCart version 1.5.1 and below, you need to disable the counting function directly in the site code. To do this, do the following:
  1. Edit the file catalog/controller/common/header.php:
    1. On about 200th line, 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. You should end up with something like this:
      //$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 is working.