Rev 12228 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Products 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('product_model');$this->load->model('magento_model');$this->layoutName= $this->layout->getLayout();$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';}public function index(){$last = $this->uri->total_segments();$itemcode = $this->uri->segment($last);$itemName = $this->uri->segment($last-1);//standard array$data = array();//get cache$configdata =array();$configdata = $this->config->item('productlist');if(is_numeric($itemcode) && ($itemName == 'coming-soon')) {unset($configdata['response'][0]);unset($configdata['response'][1]);unset($configdata['response'][3]);}elseif(is_numeric($itemcode) && ($itemName == 'best-deals')){unset($configdata['response'][0]);unset($configdata['response'][1]);unset($configdata['response'][2]);}elseif(is_numeric($itemcode) && ($itemcode != 1)) {unset($configdata['response'][1]);unset($configdata['response'][2]);unset($configdata['response'][3]);}elseif(is_string($itemcode)) {unset($configdata['response'][0]);unset($configdata['response'][2]);unset($configdata['response'][3]);}$name = $configdata['response'];foreach ($name as $key => $value) {$name = $value;}$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(empty($_GET)){if($itemName != 'coming-soon' && $itemName !== 'best-deals'){$productName = $itemcode;}elseif($itemName == 'coming-soon' || $itemName == 'best-deals') {$productName = $itemName;}if(isset($productName) && !empty($productName) && !isset($authorized['isPrivateDealUser'])) {$cache = getFileCache($productName);}if(isset($cache) && !empty($cache)){$data['response'] = $cache;}else{$data['response']=$this->product_model->getProducts('',$this->input->post(),$configdata['module'], $itemcode,$_SERVER['QUERY_STRING']);if(isset($productName)) {if(!isset($authorized['isPrivateDealUser'])) {setFileCache($data['response'], $productName,300);}}}}else{$data['response']=$this->product_model->getProducts('',$this->input->post(),$configdata['module'], $itemcode,$_SERVER['QUERY_STRING']);}//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');$data['stylesheet'] = 'pd-list.css';if($itemName != 'coming-soon' && $itemName !== 'best-deals'){if(isset($data['response']['response'][$name][0]->result->title))$title = $data['response']['response'][$name][0]->result->title;if(isset($title) && !empty($title)){$data['title'] = $title;}if(isset($data['response']['response'][$name][0]->result->metaDescription))$metaDescription = $data['response']['response'][$name][0]->result->metaDescription;if(isset($metaDescription) && !empty($metaDescription)){$data['metaDescription'] = $metaDescription;}if(isset($data['response']['response'][$name][0]->result->metaKeywords))$metaKeywords = $data['response']['response'][$name][0]->result->metaKeywords;if(isset($metaKeywords) && !empty($metaKeywords)){$data['metaKeywords'] = $metaKeywords;}}//end of set cache$this->layout->view('products/products_view',$data);}public function getProductList($category,$page=null,$sort=null,$filter=null,$price=null){$value = intval($category);if(($value !== 0) && ($category == 1)){$url = $this->config->item('coming_soon');}elseif(($value !== 0) && ($category !=1)){$url = $this->config->item('product_list');}elseif($value == 0){$url = $this->config->item('special_page');}$url = $url['url'];$url = $this->config->item('curl_base_url').$url.'/'.$category;$params = array();$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);}$authorized = $this->session->userdata('authorized');$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 getSpecialProductList($category,$page=null){if(isset($category) && !empty($category)){$authorized=$this->session->userdata('authorized');if($category == 'coming-soon'){$url = $this->config->item('coming_soon');}$url = $url['url'];$url = $this->config->item('curl_base_url').$url.'/'.$page;$params = array();if($authorized['Id'] > 0){$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->coming_soon($data);$count = $response[0]->response->count;$productListResponse ='';$count = $count-20;$TotalPage = ceil($count/10);if($TotalPage < $page) {$coming_soon='';}else{$coming_soon = $response;}if(isset($coming_soon) and !empty($coming_soon)){foreach($coming_soon[0]->response->items 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('filter');$data['response']=$this->product_model->getProducts($this->input->get(),$this->input->post(),$configdata);$this->layout->view('products/products_view',$data);}}/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */