Subversion Repositories SmartDukaan

Rev

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

Rev 18004 Rev 18013
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;
129
		$error = $this->request->query('error');
130
		$error = $this->request->query('error');
130
		if(!isset($page)){
131
		if(!isset($page)){
131
			$page = 1;
132
			$page = 1;
132
		}
133
		}
133
 
134
 
Line 252... Line 253...
252
			
253
			
253
			if(isset($error)){
254
			if(isset($error)){
254
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
255
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
255
			}
256
			}
256
 
257
 
-
 
258
			// if($id != undefined){
-
 
259
				$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
-
 
260
			// }
-
 
261
			
-
 
262
			// echo "<br>".$nexturl;
257
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr'));
263
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr','nexturl'));
258
		}else{
264
		}else{
259
			//Check for apk support of sharing
265
			//Check for apk support of sharing
260
			$sharable = 0;
266
			$sharable = 0;
261
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
267
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
262
				$sharable = 1;
268
				$sharable = 1;
Line 381... Line 387...
381
	  	if(!empty($subcategorieschosen) && isset($subcategorieschosen)&& empty($brandschosen) && !isset($brandschosen)){
387
	  	if(!empty($subcategorieschosen) && isset($subcategorieschosen)&& empty($brandschosen) && !isset($brandschosen)){
382
 
388
 
383
	  			$filterstr= "&filter=subcategory&subcategories=".$subcategorieschosen;
389
	  			$filterstr= "&filter=subcategory&subcategories=".$subcategorieschosen;
384
	  	}
390
	  	}
385
 
391
 
-
 
392
	  	$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
386
 
393
 
387
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
394
		$this->set(compact('nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
388
		if(!empty($deals) && !empty($deals[0])){
395
		if(!empty($deals) && !empty($deals[0])){
389
			$this->render('/Elements/deals');
396
			$this->render('/Elements/deals');
390
		}else{
397
		}else{
391
			$this->render('/Elements/nodeals');
398
			$this->render('/Elements/nodeals');
392
		}
399
		}
393
 
400
 
394
 
401
 
395
 
402
 
396
	}
403
	}
-
 
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
	}
397
/**
503
/**
398
 * add method
504
 * add method
399
 *
505
 *
400
 * @return void
506
 * @return void
401
 */
507
 */