public function productsView() { $ui_array = array('order_by', 'page', 'id', 'brand_id'); Session::loadUIVars('ui_catalogue', $ui_array); if (!isset($_GET['page']) || $_GET['page'] == '') { $_GET['page'] = 1; } if (!isset($_GET['id']) || $_GET['id'] == '') { $_GET['id'] = 0; } if (!isset($_GET['order_by']) || $_GET['order_by'] == '') { $_GET['order_by'] = 'id'; } if (!isset($_GET['brand_id']) || $_GET['brand_id'] == '') { $_GET['brand_id'] = 0; } $this->c->assign('order_by', $_GET['order_by']); $this->c->assign('page', $_GET['page']); $this->c->assign('category_id', $_GET['id']); $this->buildNav(); $p = Model::load('ProductItem'); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $showCat = $_GET['id']; } else { $showCat = 0; } $sql = ' WHERE category_id = ' . $_GET['id']; if ($_GET['brand_id'] > 0) { $sql .= ' AND brand_id = ' . $_GET['brand_id']; } // status $sql .= ' AND status != ' . ProductItemStatus::DELETED; // vendor $v = Model::load('Vendor'); $vendor_id = $v->getIDByUserID(CurrentUser::getUserID()); $sql .= ' AND vendor_id = ' . $vendor_id; $sql .= ' ORDER BY ' . $_GET['order_by']; $p_nav = $p->getPaginatePages(Model::getTable('ProductItem'), $sql, $_GET['page'], REQUESTS_PER_PAGE); $this->c->assign('p_nav', $p_nav); $product = $p->getAllCustomPaginate(Model::getTable('ProductItem'), $sql, $_GET['page'], REQUESTS_PER_PAGE); foreach ($product as &$p_item) { $p_item['status_text'] = ProductItemStatus::getStatus($p_item['status']); //$p_item['min_price'] = $p->getMinPrice($p_item['id']); // min price is now stored in products table } $c = Model::load('CategoryItem'); $c->id = $_GET['id']; $category = $c->loadIndexed($c->category_id); $this->c->assign("products", $product); }