Subversion Repositories SmartDukaan

Rev

Rev 19992 | Rev 20127 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19992 Rev 20103
Line 20... Line 20...
20
	public $apihost;	
20
	public $apihost;	
21
	public $livepriceurl;
21
	public $livepriceurl;
22
 
22
 
23
	public function beforeFilter() {
23
	public function beforeFilter() {
24
		parent::beforeFilter();
24
		parent::beforeFilter();
25
		$this->Auth->allow('bycategory','category','mine','getdeals','getliveprice','search','filter','skus');
25
// 		$this->Auth->allow('bycategory','category','mine','getdeals','getliveprice','search','filter','skus');
26
		$callback = $this->request->query('callback');	
26
		$callback = $this->request->query('callback');	
27
		$this->livepriceurl = Configure::read('livepriceurl');	
27
		$this->livepriceurl = Configure::read('livepriceurl');	
28
	}
28
	}
29
 
29
 
30
	public function filter($type='brand',$categoryId=3){
30
	public function filter($type='brand',$categoryId=3){
Line 43... Line 43...
43
		$this->set(compact('brands','categoryId'));
43
		$this->set(compact('brands','categoryId'));
44
	}	
44
	}	
45
 
45
 
46
	public function search() {
46
	public function search() {
47
		$userId = $this->request->query('user_id');
47
		$userId = $this->request->query('user_id');
48
		if(isset($userId) && !empty($userId)){
48
// 		if(isset($userId) && !empty($userId)){
49
			$this->loadModel('User');
49
// 			$this->loadModel('User');
50
			$dbuser = $this->User->findById($userId);
50
// 			$dbuser = $this->User->findById($userId);
51
			$this->Auth->login($dbuser['User']);
51
// 			$this->Auth->login($dbuser['User']);
52
		}
52
// 		}
53
		$this->layout = 'innerpages';
53
		$this->layout = 'innerpages';
54
		$q = $this->request->query('q');
54
		$q = $this->request->query('q');
55
		$page = $this->request->query('page');
55
		$page = $this->request->query('page');
56
		if(!isset($page)){
56
		if(!isset($page)){
57
			$page = 1;
57
			$page = 1;
Line 89... Line 89...
89
		}
89
		}
90
	}
90
	}
91
 
91
 
92
	public function mine() {		
92
	public function mine() {		
93
		$userId = $this->request->query('user_id');
93
		$userId = $this->request->query('user_id');
94
		if(isset($userId) && !empty($userId)){
94
// 		if(isset($userId) && !empty($userId)){
95
			$this->loadModel('User');
95
// 			$this->loadModel('User');
96
			$dbuser = $this->User->findById($userId);
96
// 			$dbuser = $this->User->findById($userId);
97
			$this->Auth->login($dbuser['User']);
97
// 			$this->Auth->login($dbuser['User']);
98
		}
98
// 		}
99
		// $this->checkMobileNumber();
99
		// $this->checkMobileNumber();
100
		$likedDeals = $disLikedDeals = array();
100
		$likedDeals = $disLikedDeals = array();
101
		$this->loadModel('Api');
101
		$this->loadModel('Api');
102
		$page = $this->request->query('page');
102
		$page = $this->request->query('page');
103
		if(!isset($page)){
103
		if(!isset($page)){
Line 247... Line 247...
247
 * @param string $id
247
 * @param string $id
248
 * @return void
248
 * @return void
249
 */
249
 */
250
	public function view($id = null,$bundleId=null) {
250
	public function view($id = null,$bundleId=null) {
251
		$userId = $this->request->query('user_id');
251
		$userId = $this->request->query('user_id');
252
		if(isset($userId) && !empty($userId)){
252
// 		if(isset($userId) && !empty($userId)){
253
			$this->loadModel('User');
253
// 			$this->loadModel('User');
254
			$dbuser = $this->User->findById($userId);
254
// 			$dbuser = $this->User->findById($userId);
255
			$this->Auth->login($dbuser['User']);
255
// 			$this->Auth->login($dbuser['User']);
256
		}
256
// 		}
257
		$this->layout = "innerpages";
257
		$this->layout = "innerpages";
258
		$cachekey = 'storeproduct-'.$id;
258
		$cachekey = 'storeproduct-'.$id;
259
		// $product = Cache::read($cachekey,'fivemin');
259
		// $product = Cache::read($cachekey,'fivemin');
260
		if(empty($product)) {
260
		if(empty($product)) {
261
			$url = $this->apihost.'masterData/getSkuById/'.$id.'?showDp=1';
261
			$url = $this->apihost.'masterData/getSkuById/'.$id.'?showDp=1';
Line 274... Line 274...
274
		// if(empty($products)) {
274
		// if(empty($products)) {
275
		session_write_close();
275
		session_write_close();
276
		$result = array();
276
		$result = array();
277
		$this->response->type('json');
277
		$this->response->type('json');
278
		$this->layout = 'ajax';
278
		$this->layout = 'ajax';
279
		$dealpin = $this->getpin();
279
// 		$dealpin = $this->getpin();
280
		$url = $this->livepriceurl."?skuBundleId=$bundleId&source_id=$storeId";
280
		$url = $this->livepriceurl."?skuBundleId=$bundleId&source_id=$storeId";
281
		$url = $url."&pin=".$dealpin;
281
// 		$url = $url."&pin=".$dealpin;
282
		$products = $this->make_request($url,null);
282
		$products = $this->make_request($url,null);
283
			// Cache::write($cachekey,$products,'fivemin');			
283
			// Cache::write($cachekey,$products,'fivemin');			
284
		// }
284
		// }
285
		if(!empty($products)){
285
		if(!empty($products)){
286
			$result['products'] = array();
286
			$result['products'] = array();