OpenCart is surely one of the best open source E-commerce framework available now. Its extensive and fast enough too. Here is one tip for a particular scenario you may face when you are building an OC based E-commerce website.
If you want to list or display all products of subcategories under a parent category on the parent category page, I will explain again,
consider a Mobile Phone e-shop, it has 4 brands of mobiles such as Nokia, Samsung, Sony and Apple and these sub menu / sub category of a parent menu/category as Brands.
Obviously, when you click on each sub categories such Nokia, Apple etc, it will display products under that but if you need to display all the products when you click on BRANDS, then what should you do ?
well its very simple..
NOTE:- take backup of original files you are going to edit. this is very very important.
go here.. In catalog/controller/product/category.php (or wherever you’re calling function model_catalog_product->getProducts) you have to add this line
filter_sub_category = true:
into this part of code snippet
$data = array( 'filter_category_id' => $top_category, 'filter_sub_category' => true, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit ); $product_total = $this->model_catalog_product->getTotalProducts($data);
Thats all.. now you click on the Parent category, it will show all categories under that one. But one problem, what about Refine search. Now both are mixed right? One thing to do, just remove the refine search code. Code snippet lies in this file.
open this file /catalog/view/theme/your_theme/template/product/product.tpl and find the lines where refine search is listed. Just delete or comment those lines.