Rev 12694 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Search extends MY_Controller {public $layoutName ='';function __construct() {// Call the CI_controller constructorparent::__construct();// $admin = $this->session->userdata('admin');// if(!isset($admin) || empty($admin)) {// redirect(base_url().'authorize');// }$this->layout->setlayout('layout/layout_main');$this->load->model('search_model');$this->load->model('magento_model');$this->layoutName= $this->layout->getLayout();$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';}public function index(){//standard array$data = array();//get cache$configdata =array();$configdata = $this->config->item('searchlist');$cachemodule = array('header','footer');$configdata = getCache($configdata,$cachemodule);$authorized = $this->session->userdata('authorized');if($authorized['Id'] > 0){$_SERVER['QUERY_STRING'] .= '&userId='.$authorized['Id'].'&isLoggedIn=true';}if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {$_SERVER['QUERY_STRING'] .= '&privateDealUser=true';}//end of get cacheif(array_key_exists('fq', $_GET) || array_key_exists('sortedBy', $_GET) || array_key_exists('minPrice', $_GET)){$data['response']=$this->search_model->getProducts($this->input->get(),$this->input->post(),$configdata['module'],$_SERVER['QUERY_STRING']);}else{$searchName = 'seacrh'.$this->input->get('q');//Anikendra: default search page should display all productsif($this->input->get('q')==''){redirect(base_url().'search/?q=*');}if(!isset($authorized['isPrivateDealUser'])) {$cache = getFileCache($searchName);}if(isset($cache) && !empty($cache)){$data['response'] = $cache;}else{$data['response']=$this->search_model->getProducts($this->input->get(),$this->input->post(),$configdata['module']);if(!isset($authorized['isPrivateDealUser'])) {setFileCache($data['response'], $searchName,300);}}}//set cache to output or renew cacheif(isset($cachemodule) and !empty($cachemodule)){foreach($cachemodule as $cm){if(isset($configdata[$cm]) and !empty($configdata[$cm])){$data['response'][$cm]=$configdata[$cm];}}}setCache($configdata['module'],$cachemodule,$data['response']);$this->lessphp->object()->ccompile('assets/css/pd-list.less','assets/css/pd-list.css');if(isset($data['response']['response']['search_list'][0]->result->label))$title = $data['response']['response']['search_list'][0]->result->label;if(isset($title) && !empty($title)){$data['title'] = $title;}if(isset($data['response']['response']['search_list'][0]->result->metaDescription))$metaDescription = $data['response']['response']['search_list'][0]->result->metaDescription;if(isset($metaDescription) && !empty($metaDescription)){$data['metaDescription'] = $metaDescription;}if(isset($data['response']['response']['search_list'][0]->result->metaKeywords))$metaKeywords = $data['response']['response']['search_list'][0]->result->metaKeywords;if(isset($metaKeywords) && !empty($metaKeywords)){$data['metaKeywords'] = $metaKeywords;}$data['stylesheet'] = 'pd-list.css';//end of set cache$this->layout->view('search/search_view',$data);}public function getSearchList($page,$name,$sort=null,$filter=null,$price=null){$authorized=$this->session->userdata('authorized');$url = $this->config->item('search_list');$url = $url['url'];$url = $this->config->item('curl_base_url').$url;$params['q'] = rawurldecode($name);$params['index'] = ($page-1)*10;$params['offset'] = 10;if(isset($sort) && $sort != 'null'){$params['sortedBy'] = $sort;}if(isset($price) && $price != 'null'){$price = explode('&', $price);if(intval($price[0]) < intval($price[1])){$params['minPrice'] = $price[0];$params['maxPrice'] = $price[1];}else{$params['minPrice'] = $price[1];$params['maxPrice'] = $price[0];}}if(isset($filter) && $filter != 'null'){$url .= '?fq='.rawurldecode($filter);}if($authorized['Id'] > 0){if(strpos($url,'?')===false){$url .= '?userId='.$authorized['Id'].'&isLoggedIn=true';}else{$url .= '&userId='.$authorized['Id'].'&isLoggedIn=true';}}if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {$url .= '&privateDealUser=true';}$this->mcurl->add_call('appendlist','get',$url,$params);$response = $this->mcurl->execute($url);$data['response'] = $response['appendlist']['response'];$response = $this->magento_model->product_list($data);$count = $response[0]->result->totalCount;$productListResponse ='';$TotalPage = ceil($count/10);if($TotalPage < $page) {$product_list='';}else{$product_list = $response;}if(isset($product_list) and !empty($product_list)){foreach($product_list[0]->result->results as $pl){if(isset($pl->image_url) and !empty($pl->image_url)){$productListResponse .= '<a class="pd-list" href="'. base_url().$pl->url.'"><div class="pd-image" style="background:url(\''.$pl->image_url.'\')no-repeat center center;background-size:contain;"></div>';if(!isset($authorized['isPrivateDealUser']) || !isset($pl->dealprice)) {$productListResponse .= '<div class="pd-info"><div class="pdt-name">'.$pl->title.'</div><div class="pdt-price">';if(isset($pl->price) || isset($pl->mrp)){$productListResponse .='<span class="pr">Rs</span>';if(isset($pl->mrp) && $pl->mrp != 0){$productListResponse .='<span class="pr-linethrough">'.$pl->mrp.'</span>';}if(isset($pl->price) && $pl->price != 0){$productListResponse .='<span class="pr-original">'. $pl->price.'</span>';}}$productListResponse .='</div><div class="pdt-spec">'. $pl->description.' </div></div></a>';} else{$productListResponse .= '<div class="pd-info"><div class="pdt-name">'.$pl->title.'</div><div class="pdt-price"><span class="pricetype">Site Price</span>';if(isset($pl->price) || isset($pl->mrp)){$productListResponse .='<span class="pr">Rs</span>';if(isset($pl->mrp) && $pl->mrp != 0){$productListResponse .='<span class="pr-linethrough">'.$pl->mrp.'</span>';}if(isset($pl->price) && $pl->price != 0){$productListResponse .='<span class="pr-linethrough">'.$pl->price.'</span>';}}if(isset($pl->dealprice) && $pl->dealprice != 0){$productListResponse .='</div><div class="pdt-price pdeal-price"><span class="pricetype">Your Price</span><span class="pr">Rs</span> <span class="pr-original">'.$pl->dealprice.'</span></div>';}if(isset($pl->offer_text) && !empty($pl->offer_text)) {$productListResponse .= '<div class="pdt-offertext">'.$pl->offer_text.'</div>';}$productListResponse .='<div class="pdt-spec">'. $pl->description.' </div>';if(isset($pl->dealcolors) && !empty($pl->dealcolors) && trim($pl->dealcolors[0])!='') {$productListResponse .= '<div class="pdt-offercolors">Offer available for : '.implode(',',$pl->dealcolors).'</div>';}$productListResponse .= '</div></a>';}}}}echo $productListResponse;}public function filter(){$configdata = $this->config->item('searchfilter');$data['response']=$this->search_model->getProducts($this->input->get(),$this->input->post(),$configdata);$this->layout->view('search/search_view',$data);}}/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */