I am using OpenCart 2
and I want to modify the default category module to show me only the subcategories of the current category up to a level 3.
For example, if I am on the “Laptops & Desktops” category page, the sidebar module would only list the sub-categories associated with “Laptops & Desktops” category, such as “Macs” and “PCs” with the main heading “Laptops & Desktops” (And not list or show any of the other top level categories). In addition to that I want it to show the subcategories of "Macs" and "PCs" too.
Laptops & Desktops
-- Macs
---- Subcategory 1
-- PCs
---- Subcategory 1
---- Subcategory 2
If I go to category PCs I will see:
PCs
-- Subcategory 1
-- Subcategory 2
Thank you!
Download “Show only subcategories on category page OpenCart 2.0 free module” from link below: Download Show Only SubCategories
Please download as per version. There is one version for 2.2 and another version for 2.0
You need into change core file catalog → controller → module → category.php
replace
$categories = $this->model_catalog_category->getCategories(0);
with following
> $parts = explode('_', (string)$this->request->get['path']);
> $category_id = (int)array_pop($parts);
> $categories = $this->model_catalog_category->getCategories($category_id);