/
filter.php
74 lines (56 loc) · 2.06 KB
/
filter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
class ControllerExtensionModuleFilter extends Controller {
public function index() {
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}
$category_id = end($parts);
$this->load->model('catalog/category');
$category_info = $this->model_catalog_category->getCategory($category_id);
if ($category_info) {
$this->load->language('extension/module/filter');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['action'] = str_replace('&', '&', $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url));
if (isset($this->request->get['filter'])) {
$data['filter_category'] = explode(',', $this->request->get['filter']);
} else {
$data['filter_category'] = array();
}
$this->load->model('catalog/product');
$data['filter_groups'] = array();
$filter_groups = $this->model_catalog_category->getCategoryFilters($category_id);
if ($filter_groups) {
foreach ($filter_groups as $filter_group) {
$childen_data = array();
foreach ($filter_group['filter'] as $filter) {
$filter_data = array(
'filter_category_id' => $category_id,
'filter_filter' => $filter['filter_id']
);
$childen_data[] = array(
'filter_id' => $filter['filter_id'],
'name' => $filter['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : '')
);
}
$data['filter_groups'][] = array(
'filter_group_id' => $filter_group['filter_group_id'],
'name' => $filter_group['name'],
'filter' => $childen_data
);
}
return $this->load->view('extension/module/filter', $data);
}
}
}
}