Post by reto » Wed Dec 03, 2014 6:44 pm

Hi

I strucle to get the category module to display all items, also child items, at all time. No collapse of the child items.

Anybody Knows the solution? :)

Thanks for your help
Reto

Newbie

Posts

Joined
Mon Nov 17, 2014 6:54 pm

Post by pprmkr » Wed Dec 03, 2014 10:31 pm

First edit catalog/controller/module/category.php
Change:

Code: Select all

			if ($category['category_id'] == $data['category_id']) {
				$children = $this->model_catalog_category->getCategories($category['category_id']);

				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'])
					);
				}
			}
Into:

Code: Select all

//			if ($category['category_id'] == $data['category_id']) {
				$children = $this->model_catalog_category->getCategories($category['category_id']);

				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'])
					);
				}
//			}
Then edit catalog/view/theme/default/template/module/category.tpl

Replace content with:

Code: Select all

<div class="list-group">
  <?php foreach ($categories as $category) { ?>
  <?php if ($category['category_id'] == $category_id) { ?>
  <a href="<?php echo $category['href']; ?>" class="list-group-item active"><?php echo $category['name']; ?></a>
  <?php } else { ?>
  <a href="<?php echo $category['href']; ?>" class="list-group-item"><?php echo $category['name']; ?></a>
  <?php } ?>
  <?php if ($category['children']) { ?>
  <?php foreach ($category['children'] as $child) { ?>
  <?php if ($child['category_id'] == $child_id) { ?>
  <a href="<?php echo $child['href']; ?>" class="list-group-item active">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
  <?php } else { ?>
  <a href="<?php echo $child['href']; ?>" class="list-group-item">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
  <?php } ?>
  <?php } ?>
  <?php } ?>
  <?php } ?>
</div>

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by reto » Sun Dec 07, 2014 12:23 am

Thanks for the help :) Works fine.

Reto

Newbie

Posts

Joined
Mon Nov 17, 2014 6:54 pm

Post by dzastinaslt » Sun Dec 07, 2014 5:12 am

Hi,

This is so strange. I actually would like to have it collapsable, but in my case the module just has direct links to father category even if it has sub-categories... It is strange not to see any list scheme in OC 2.0 category module template?.. I'm working on new theme, I thought maybe I broke the template but it's the same with default template... I didn't made any changes to core/controller files.

New member

Posts

Joined
Mon Mar 05, 2012 6:01 pm
Who is online

Users browsing this forum: No registered users and 8 guests