Post by donaceli » Fri Aug 07, 2015 3:24 pm

Hi, I was trying to find the answer to this online without any luck. I want the category module to be expanded and display subcategories all the time. I don't want it to show all the subcategories, but only the first child ones. Can anyone help me with this? I tried to remove some code from the category.php, but that didn't work. The version of opencart is 2.0.2.0


Cheers!

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by donaceli » Sun Aug 30, 2015 5:49 pm

Can anyone help me with this? Much appreciated!

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by straightlight » Sun Aug 30, 2015 10:02 pm

In catalog/controller/module/category.php file,

find:

Code: Select all

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

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

Code: Select all

foreach($children as $key => $child) {
    if ((int)$key % sizeof($children) == 0) {
					$filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);

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

                                        }
}
This should resolved the problem.
Last edited by straightlight on Thu Sep 03, 2015 11:03 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Administrator

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by donaceli » Sun Aug 30, 2015 11:55 pm

I appreciate your time in writing this.

However, when I click on the category I can only see the first child but all other subcategories are hidden. Any suggestions?

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by straightlight » Mon Aug 31, 2015 12:36 am

donaceli wrote:I appreciate your time in writing this.

However, when I click on the category I can only see the first child but all other subcategories are hidden. Any suggestions?
According to your first request:
I don't want it to show all the subcategories, but only the first child ones
This is what should be intended to do after my modifications above.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Administrator

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by donaceli » Thu Sep 03, 2015 8:34 pm

Sorry I haven't explained my intention clearly.

I am looking to have a structure in my sidebar such as this:

Category/Sub-Category

I have many categories and I want to see the list expanded at all times to show the first list of sub-categories for each of them.

I hope this helps. Thanks!

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by straightlight » Thu Sep 03, 2015 11:04 pm

donaceli wrote:Sorry I haven't explained my intention clearly.

I am looking to have a structure in my sidebar such as this:

Category/Sub-Category

I have many categories and I want to see the list expanded at all times to show the first list of sub-categories for each of them.

I hope this helps. Thanks!
I have now edited my instructions above.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Administrator

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by donaceli » Mon Sep 07, 2015 10:28 pm

Thank you for the effort but I am still not getting the structure I am looking for. Perhaps I am unable to explain myself properly. This would be the structure I am aiming for:


House
- Furniture
- TV Sets
- Equipment

Car
- Exterior parts
- Interior parts
- Suspension parts

and so on. The furniture and other first child elements would have subcategories which I don't want to be expanded. Currently only the active Parent's subcategories are visible. With your code I can see the parent and the first child element such as House - Furniture.

Thanks a lot.

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by wiseprt » Wed Apr 06, 2016 9:33 pm

Hello,

I want to display in the left sidebar the 3rd level of the categories and not only the categories / subcategories.

For example i have the following category tree:

Cat1
-Sub Cat 1
- - 3rd Level Cat 1

-Sub Cat 2
- - 3rd Level Cat 1
- - 3rd Level Cat 2

When i am on Sub Cat 1 i want to display in left sidebar the 3rd Level Cat 1.
My opencart version is 2.0.0.2

Any ideas?

Best Regards

Newbie

Posts

Joined
Wed Apr 06, 2016 9:23 pm

Post by bolson67 » Tue May 24, 2016 1:34 am

I am interested in the same thing. Did you find a solution?

Newbie

Posts

Joined
Mon Sep 03, 2012 12:15 pm

Post by donaceli » Wed Jun 22, 2016 8:36 pm

Haven't found the solution yet. There are extensions that can be purchased, but I would love to do this within opencart core.

New member

Posts

Joined
Thu Jun 11, 2015 5:53 pm

Post by straightlight » Wed Jun 22, 2016 8:42 pm


The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Administrator

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Usha123 » Wed Feb 28, 2018 8:51 pm

Hello everyone,

I have a problem :
if (product has subcategories) { then list out subcategories }
else {list out products and on click of title show popup}
Please, help me. (reference link : http://rajathgalleria.com/products)

Newbie

Posts

Joined
Wed Feb 28, 2018 8:47 pm

Post by dalibor » Fri Mar 23, 2018 2:04 am


New member

Posts

Joined
Fri Mar 14, 2014 6:12 am
Who is online

Users browsing this forum: pex48 and 76 guests