Subversion Repositories SmartDukaan

Rev

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

Rev 18013 Rev 18017
Line 124... Line 124...
124
			$this->loadModel('User');
124
			$this->loadModel('User');
125
			$dbuser = $this->User->findById($userId);
125
			$dbuser = $this->User->findById($userId);
126
			$this->Auth->login($dbuser['User']);
126
			$this->Auth->login($dbuser['User']);
127
		}				
127
		}				
128
		$page = $this->request->query('page');
128
		$page = $this->request->query('page');
129
		// echo "page=>",$page;
-
 
130
		$error = $this->request->query('error');
129
		$error = $this->request->query('error');
131
		if(!isset($page)){
130
		if(!isset($page)){
132
			$page = 1;
131
			$page = 1;
133
		}
132
		}
134
 
133
 
Line 253... Line 252...
253
			
252
			
254
			if(isset($error)){
253
			if(isset($error)){
255
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
254
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
256
			}
255
			}
257
 
256
 
258
			// if($id != undefined){
-
 
259
				$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
-
 
260
			// }
-
 
261
			
-
 
262
			// echo "<br>".$nexturl;
-
 
263
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr','nexturl'));
257
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr'));
264
		}else{
258
		}else{
265
			//Check for apk support of sharing
259
			//Check for apk support of sharing
266
			$sharable = 0;
260
			$sharable = 0;
267
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
261
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
268
				$sharable = 1;
262
				$sharable = 1;
Line 387... Line 381...
387
	  	if(!empty($subcategorieschosen) && isset($subcategorieschosen)&& empty($brandschosen) && !isset($brandschosen)){
381
	  	if(!empty($subcategorieschosen) && isset($subcategorieschosen)&& empty($brandschosen) && !isset($brandschosen)){
388
 
382
 
389
	  			$filterstr= "&filter=subcategory&subcategories=".$subcategorieschosen;
383
	  			$filterstr= "&filter=subcategory&subcategories=".$subcategorieschosen;
390
	  	}
384
	  	}
391
 
385
 
392
	  	$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
-
 
393
 
386
 
394
		$this->set(compact('nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
387
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
395
		if(!empty($deals) && !empty($deals[0])){
388
		if(!empty($deals) && !empty($deals[0])){
396
			$this->render('/Elements/deals');
389
			$this->render('/Elements/deals');
397
		}else{
390
		}else{
398
			$this->render('/Elements/nodeals');
391
			$this->render('/Elements/nodeals');
399
		}
392
		}
400
 
393
 
401
 
394
 
402
 
395
 
403
	}
396
	}
404
 
-
 
405
 
-
 
406
	public function getdealsforsearchterm($searchterm,$page = null){
-
 
407
 
-
 
408
		// // $this->autoRender = false;	
-
 
409
		// // $this->request->onlyAllow('ajax');
-
 
410
		// $this->layout = 'ajax';
-
 
411
		// $this->autoLayout = false;
-
 
412
		// $this->autoRender = false;
-
 
413
		// // $url = $this->apihost.'urlname/'.$searchterm;
-
 
414
		// $url = "http://shop2020.in:8057/deals/2?categoryId=6&limit=1&offset=0&filterData=subCategoryFilter:12";
-
 
415
		// $getApp = $this->make_request($url,null);
-
 
416
 
-
 
417
		// $this->render('getdealsforsearchterm');
-
 
418
		
-
 
419
		// // $getdata = "Hello";
-
 
420
		// // return;
-
 
421
		// return json_encode($getApp);
-
 
422
 
-
 
423
 
-
 
424
 
-
 
425
	
-
 
426
		// $this->log('getdeal id '.$id,'api');
-
 
427
		$likedDeals = $disLikedDeals = array();
-
 
428
		$this->layout = 'ajax';
-
 
429
		$page = $this->request->query('page');
-
 
430
		if(!isset($page)){
-
 
431
			$page = 1;
-
 
432
			$offset = 0;
-
 
433
		}
-
 
434
		else{
-
 
435
			$offset = ($page*20) - 20;
-
 
436
		}
-
 
437
		$sort = $this->request->query('sort');
-
 
438
		$direction = $this->request->query('direction');
-
 
439
		// $filter = $this->request->query('filter');
-
 
440
		// $brands = $this->request->query('brands');
-
 
441
		$brandschosen = $_COOKIE['brandschosen'];	 
-
 
442
		$subcategorieschosen = $_COOKIE['subcategorieschosen']; 	
-
 
443
		
-
 
444
		// Replace with the below content
-
 
445
		// if(!empty($brandschosen)){
-
 
446
		// 	$filter = 'brand';
-
 
447
		// }
-
 
448
 
-
 
449
		//I have replaced the above content
-
 
450
		if(!empty($brandschosen) && !empty($subcategorieschosen)){
-
 
451
			$filter = 'brand|subcategory';
-
 
452
		}			
-
 
453
		else if(!empty($brandschosen) && empty($subcategorieschosen)){
-
 
454
			$filter = 'brand';
-
 
455
		}
-
 
456
		if(!empty($subcategorieschosen) && empty($brandschosen)){
-
 
457
			$filter = 'subcategory';
-
 
458
		}
-
 
459
		//Replaced end
-
 
460
 
-
 
461
		$brands = str_replace(',', '^', $brandschosen);
-
 
462
		$subcategories = str_replace(',', '^', $subcategorieschosen);
-
 
463
		$url = "http://45.79.106.95:8057/searchSubCategory/?offset=".$offset."&limit=20&searchTerm=".$searchterm."&subCategoryId=".$subcategorieschosen;
-
 
464
		$response = $this->make_request($url,null);
-
 
465
		$deals = array();
-
 
466
		if(!empty($response)){
-
 
467
			foreach ($response as $key => $value) {
-
 
468
				if(!empty($value)){
-
 
469
					$deals[] = $value;
-
 
470
				}
-
 
471
			}
-
 
472
		}
-
 
473
		// if (!$this->Category->exists($id)) {
-
 
474
			// throw new NotFoundException(__('Invalid category'));
-
 
475
		// }
-
 
476
		$this->loadModel('Api');
-
 
477
		// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
-
 
478
		// $deals = $apideals['products'];
-
 
479
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
-
 
480
		if(!empty($myactions)) {
-
 
481
			foreach ($myactions['actions'] as $key => $value) {
-
 
482
				if($value['UserAction']['action'] == 'like'){
-
 
483
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
484
				}else{
-
 
485
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
486
				}
-
 
487
			}
-
 
488
		}
-
 
489
		
-
 
490
 
-
 
491
	  	// $nexturl = "/categories/getdealsforsearchterm/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
-
 
492
		$nexturl = "/categories/getdealsforsearchterm/".$searchterm."/?page=".($page+1);
-
 
493
		// $nexturl = "#";
-
 
494
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','nexturl'));
-
 
495
		if(!empty($deals) && !empty($deals[0])){
-
 
496
			$this->render('/Elements/deals');
-
 
497
		}else{
-
 
498
			$this->render('/Elements/nodeals');
-
 
499
		}
-
 
500
 
-
 
501
 
-
 
502
	}
-
 
503
/**
397
/**
504
 * add method
398
 * add method
505
 *
399
 *
506
 * @return void
400
 * @return void
507
 */
401
 */