public function fetch_products($cat, $search, $start_price, $end_price, $sorting, $rating, $discount, $limit, $offset) { $search_array = explode(',', $search); if ($cat != null && $cat != 'All') { if ($start_price == null && $end_price == null && $rating == null && $discount == null) { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan !=', 'Reseller') ->where('product_category', $cat) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item, 'both') ->or_like('sub_category', $search_item, 'both') ->or_like('sub_sub_category', $search_item, 'both') ->or_like('product_category', $search_item, 'both') ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan !=', 'Reseller') ->where('product_category', $cat) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } // $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') // ->from('uthhan_product') // ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) // ->where('product_category', $cat) // ->where('status', 'Approved') // ->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC') // ->limit($limit, $offset); // foreach ($search_array as $search_item) { // $this->db->group_start() // ->like('product_name', $search_item) // ->or_like('sub_category', $search_item) // ->or_like('sub_sub_category', $search_item) // ->or_like('product_category', $search_item) // ->or_like('id', $search_item) // ->group_end(); // } // ->get(); // if ($query->num_rows() > 0) { // return $query->result(); // } else { // return false; // } } else if ($sorting == 'price-high') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } else { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,product_rating_average,uthhan_charge,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == "price-high") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('product_category', $cat) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } } else if ($cat == "All") { if ($start_price == null && $end_price == null && $rating == null && $discount == null) { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == "price-high") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { foreach ($search_array as $search_item) { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } } else { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == "price-high") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } } else { if ($start_price == null && $end_price == null && $rating == null && $discount == null) { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == "price-high") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved'); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } else { if ($sorting == "date") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == 'price-low') { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') // ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'ASC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else if ($sorting == "price-high") { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('(selling_price*(110/100))*((gst+100)/100)', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } else { $query = $this->db->select('id,product_name,mrp,uthhan_charge,product_rating_average,product_category,sub_category,sub_sub_category,selling_price,gst,image_url_1') ->from('uthhan_product') ->where('reseller_uthhan!=', 'Reseller') ->where("(product_name LIKE '%" . $search . "%' OR sub_category LIKE '%" . $search . "%' OR sub_sub_category LIKE '%" . $search . "%' OR product_category LIKE '%" . $search . "%' OR id LIKE '%" . $search . "%')", NULL, FALSE) ->where('status', 'Approved') ->where('(selling_price*(110/100))*((gst+100)/100) >=', $start_price) ->where('(selling_price*(110/100))*((gst+100)/100) <=', $end_price); foreach ($search_array as $search_item) { $this->db->group_start() ->like('product_name', $search_item) ->or_like('sub_category', $search_item) ->or_like('sub_sub_category', $search_item) ->or_like('product_category', $search_item) ->or_like('id', $search_item) ->group_end(); } $query->order_by('id', 'DESC')->limit($limit, $offset); $result = $query->get(); if ($result->num_rows() > 0) { return $result->result(); } else { return false; } } } } }