-
Notifications
You must be signed in to change notification settings - Fork 45
/
supplier.php
70 lines (58 loc) · 2.27 KB
/
supplier.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
<?php
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
//will be initialized bellow...
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
$rewrited_url = null;
if (!isset($objectType))
$objectType = 'supplier';
$className = ucfirst($objectType);
$errors = array();
if ($id = intval(Tools::getValue('id_'.$objectType)))
{
include(dirname(__FILE__).'/product-sort.php');
$object = new $className(intval($id), $cookie->id_lang);
if (!Validate::isLoadedObject($object))
$errors[] = Tools::displayError('object does not exist');
else
{
/* rewrited url set */
if ($objectType == 'supplier')
$rewrited_url = $link->getSupplierLink($object->id, $object->link_rewrite);
elseif ($objectType == 'manufacturer')
$rewrited_url = $link->getManufacturerLink($object->id, $object->link_rewrite);
include(dirname(__FILE__).'/header.php');
$nbProducts = $object->getProducts($id, NULL, NULL, NULL, $orderBy, $orderWay, true);
include(dirname(__FILE__).'/pagination.php');
$smarty->assign(array(
'nb_products' => $nbProducts,
'products' => $object->getProducts($id, intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay),
$objectType => $object));
}
$smarty->assign(array(
'errors' => $errors,
'path' => Tools::safeOutput($object->name),
'id_lang' => intval($cookie->id_lang),
));
$smarty->display(_PS_THEME_DIR_.$objectType.'.tpl');
}
else
{
include(dirname(__FILE__).'/header.php');
$data = call_user_func(array($className, 'get'.$className.'s'), false, intval($cookie->id_lang), true);
$nbProducts = sizeof($data);
include(dirname(__FILE__).'/pagination.php');
$data = call_user_func(array($className, 'get'.$className.'s'), true, intval($cookie->id_lang), true, $p, $n);
$imgDir = $objectType == 'supplier' ? _PS_SUPP_IMG_DIR_ : _PS_MANU_IMG_DIR_;
foreach ($data AS &$item)
$item['image'] = (!file_exists($imgDir.'/'.$item['id_'.$objectType].'-medium.jpg')) ?
Language::getIsoById(intval($cookie->id_lang)).'-default' : $item['id_'.$objectType];
$smarty->assign(array(
'pages_nb' => ceil($nbProducts / intval($n)),
'nb'.$className.'s' => $nbProducts,
$objectType.'s' => $data
));
$smarty->display(_PS_THEME_DIR_.$objectType.'-list.tpl');
}
include(dirname(__FILE__).'/footer.php');
?>