function detail() { $id = (int) $this->uri->segment('id'); $data = $this->GetProductByID($id); if ($data->category->id_category == 0) { $orm = $this->table->db2cls(); $q = $orm->query("\n SELECT category_id_category\n FROM product_has_category\n WHERE product_id_product = {$id}\n ORDER BY RAND() LIMIT 0,1\n "); foreach ($q as $row) { $data->category->id_category = $row->category_id_category; } } if (!isset($_SESSION['previous_category_id'])) { $orm = $this->table->db2cls(); $q = $orm->query("\n SELECT category_id_category\n FROM product_has_category\n WHERE product_id_product = {$id} AND category_id_category != 1\n ORDER BY category_id_category ASC LIMIT 0,1\n "); foreach ($q as $row) { $data->category->id_category = $row->category_id_category; } } else { $data->category->id_category = $_SESSION['previous_category_id']; unset($_SESSION['previous_category_id']); } $category = new Category(); $category->product_id_except = $id; $list_product = $category->GetProductsByCategory($data->category->id_category, 16, true); Basic::currency($data->product->price_product); /** Si el ID es 19 == inicio , no imprimes nada como nombre de categoria **/ if ($data->category->id_category == 19) { $data->category->name_category = ''; } $product_attr = $this->GetAtributesByProductID($id); $this->title = $data->product->name_product; $keywords = Basic::TransVar("key_word"); $this->keywords = $data->product->{$keywords}; $allow_comment = false; $allow_rate = 'data-rateit-readonly="true"'; $client = new Client(); if ($client->_islogged()) { $allow_rate = ''; $allow_comment = true; $prod_comment = new fpp_product_rate_Model(); $prod_comment_orm = $prod_comment->db2cls(); $prod_comment_query = $prod_comment_orm->query("SELECT * FROM product_rate WHERE product_id = " . $id . " AND user_id = " . $_SESSION['conf']['client']['id']); if (count($prod_comment_query) > 0) { $allow_comment = false; } } $fpcm = new fpp_product_rate_Model(); $orm = $fpcm->db2cls(); $product_comments = $orm->fetch_where(array('product_id' => $id)); $product_comments = $orm->query("SELECT pc.comment, c.fname_client, c.lname_client, c.id_client\n FROM product_rate AS pc, client AS c\n WHERE pc.status='enable' AND pc.product_id = {$id} AND pc.user_id = c.id_client\n ORDER BY pc.dt_rated DESC"); $view = $this->ViewF("product_detail")->set("product", $data->product)->set("product_rate", $data->product_rate)->set("category", $data->category)->set("list_product", $list_product)->set("product_attr", $product_attr)->set("product_comments", $product_comments)->set("allow_comment", $allow_comment)->set("allow_rate", $allow_rate)->render(); $this->content = $view; }