function getData() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { //load visitedProduct //load userinfo bar $output['visitedProduct'] = $this->getVisitedProduct(); $output['userInfo'] = $this->getUserInfo(); //load product comment and add product to visited list $productId = $this->input->post('productId'); if ($productId != 0) { $output['productComment'] = $this->getProductComment($productId); $this->addProductCookie($productId); } //load compare product $compareCookie = $this->input->cookie('compareProduct'); $compareArray = explode(",", $compareCookie); array_push($compareArray, 0); $compareProduct = new product(); $compareProduct->where_in('id', $compareArray); $compareProduct->get_iterated(); $this->compareProduct = $compareProduct; $this->compareArray = $compareArray; $dis['base_url'] = base_url(); $output['compareProduct'] = $this->load->view('front/includes/compareProductSmall', $dis, true); $output['compareArray'] = $compareArray; //get number of cart item $output['numCart'] = $this->countCartItem(); $this->output->set_header('Content-type: application/json'); $this->output->set_output(json_encode($output)); } else { show_404(); } }
function priceTable($id = "0") { $dis['base_url'] = base_url(); if ($id != "0") { $id = explode("_", $id); $id = $id[1]; $manu = new Productmanufacture($id); $product = new product(); $product->where('productmanufacture_id', $id); $product->where('status', enum::PRODUCT_AVAILABLE); $product->order_by('name', 'asc'); $product->get_iterated(); $dis['product'] = $product; $this->load->view('front/product/ajaxPriceTable', $dis); } else { //manufacture $manu = new Productmanufacture(); $manu->where('isShow', 1); $manu->get_iterated(); $dis['manu'] = $manu; $dis['view'] = 'product/priceTable'; $this->viewfront($dis); } }
/** * Productscat::getAllProduct() * get all the product belong to a category ,direct or indirect). * @param mixed $condition * @param mixed $offset * @param mixed $limit * @return */ function getAllProduct($condition = array(), $orderBy = "id", $orderDirection = "desc", $offset = null, $limit = null) { $listChildCat = $this->getAllChildCat(); $listIntChildCat = array(); foreach ($listChildCat as $row) { array_push($listIntChildCat, $row->id); // array_push($listNameChildCat,$row->name); } array_push($listIntChildCat, $this->id); //$CI =& get_instance(); //$CI->firephp->log("child",$listNameChildCat); $product = new product(); $product->where_in_related_productcat('id', $listIntChildCat); $product->order_by($orderBy, $orderDirection); if (count($condition) > 0) { $product->where($condition); } $product->distinct(); $product->get_iterated($limit, $offset); return $product; }
function search() { $viewMode = $this->uri->segment(2, "") == "" ? "ma-tran" : $this->uri->segment(2); $orderBy = $this->uri->segment(3, "") == "" ? "moi-nhat" : $this->uri->segment(3); $page = $this->uri->segment(4, "") == "" ? "trang-1" : $this->uri->segment(4); if ($_SERVER['REQUEST_METHOD'] == "POST") { $searchKey = $this->input->post('searchKey'); $this->session->set_userdata('searchKey', $searchKey); } $searchKey = $this->session->userdata('searchkey'); $limit = $viewMode == "ma-tran" ? 15 : 10; $offset = ($this->getPageNumber($page) - 1) * $limit; $product = new Product(); if (trim($searchKey) != "") { $product->like('name', $searchKey); } $product->where('active', 1); $product->order_by($this->getOrderBy($orderBy), $this->getOrderDirection($orderBy)); $product->get_paged_iterated(); $dis['product'] = $product; $dis['pageUrl'] = "tim-kiem"; $config['base_url'] = site_url($url . "/" . $viewMode . "/" . $orderBy . "/trang-"); $config['total_rows'] = $product->paged->total_rows; $config['per_page'] = $limit; $config['use_page_numbers'] = TRUE; $config['uri_segment'] = 4; $config['num_links'] = 3; $config['full_tag_open'] = '<span class="pagin">'; $config['full_tag_close'] = "</span>"; $config['first_link'] = FALSE; $config['first_tag_open'] = ''; $config['first_tag_close'] = ''; $config['last_link'] = FALSE; $config['last_tag_open'] = ''; $config['last_tag_close'] = ''; $config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />'; $config['next_tag_open'] = ''; $config['next_tag_close'] = ''; $config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /'; $config['prev_tag_open'] = ''; $config['prev_tag_close'] = ''; $config['num_tag_open'] = ''; $config['num_tag_close'] = ''; $config['cur_tag_open'] = '<span class="active">'; $config['cur_tag_close'] = '</span>'; $this->pagination->initialize($config); if ($viewMode == 'ma-tran') { $dis['view'] = 'product/product_grid'; } else { $dis['view'] = 'product/product_list'; } $productSaleOff = new product(); $productSaleOff->where('active', 1); $productSaleOff->where('isSale', 1); $productSaleOff->order_by('id', 'desc'); $productSaleOff->get_iterated(15); $dis['productSaleOff'] = $productSaleOff; $dis['base_url'] = base_url(); $this->viewfront($dis); }