public function getProduct($id) { $result['comments'] = $this->comment->getCommentsByProduct($id); $result['categories'] = $this->category->getCategories(); $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin')); $result['isAdmin'] = Auth::isUserInRole(array('admin')); if ($result['isEditor']) { $result['product'] = $this->product->getProductWitnUnavailable($id); } else { $result['product'] = $this->product->getProduct($id); } $all_promotion = $this->promotion->getHighestActivePromotion(); $productPromotion = max($all_promotion['discount'], $result['product']['discount'], $result['product']['category_discount']); if (is_numeric($productPromotion)) { $result['product']['promotion_price'] = $result['product']['price'] - $result['product']['price'] * ($productPromotion / 100); } $result['title'] = 'Shop'; $result['currentCategory'] = $result['product']['category_id']; View::make('product', $result); if (Auth::isAuth()) { View::appendTemplateToLayout('topBar', 'top_bar.user'); } else { View::appendTemplateToLayout('topBar', 'top_bar.guest'); } View::appendTemplateToLayout('header', 'includes.header')->appendTemplateToLayout('footer', 'includes.footer')->appendTemplateToLayout('catMenu', 'side_bar.category_menu')->render(); }