-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproducts.php
47 lines (37 loc) · 1.4 KB
/
products.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
<?php
require_once "_inc/_page.php";
$text = new Text();
$text->loadByType('seo', 'products');
$page->assign("headline", $text->getHeadline());
$page->assign("text", $text->getContent());
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$limit = isset($_GET['limit']) ? $_GET['limit'] : 16;
$brandSeo = isset($_GET['brand']) ? $_GET['brand'] : null;
$categorySeo = isset($_GET['category']) ? $_GET['category'] : null;
$offer = isset($_GET['offers']) ? true : false;
$brand = new Brand();
$brand->loadByType('seo', $brandSeo);
$category = new Category();
$category->loadByType('seo', $categorySeo);
if (!$category->isNew()){
$includeCats = array($category->getId());
if ($category->getParent_category() == 0){
$children = $category->getChildren();
foreach ($children as $child){
$includeCats[] = $child['id'];
}
}
}
$product = new Product();
$meta = $product->getActiveProducts(array('brand' => $brand->getId(), 'categories' => $includeCats, 'offer' => $offer), ($offset*$limit), $limit);
$page->assign('products', $meta['products']);
$page->assign('nextPage', $offset+1);
$page->assign('previousPage', $offset-1);
if ($meta['numberOfProducts'] > ($offset*$limit)+$limit){
$page->assign('showMore', true);
} else {
$page->assign('showMore', false);
}
$page->assign('categorySeo', $categorySeo);
$page->assign('brandSeo', $brandSeo);
$page->display('products.tpl');