Subversion Repositories SmartDukaan

Rev

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

Rev 18063 Rev 18115
Line 116... Line 116...
116
 * @throws NotFoundException
116
 * @throws NotFoundException
117
 * @param string $id
117
 * @param string $id
118
 * @return void
118
 * @return void
119
 */
119
 */
120
	public function view($id = null) {
120
	public function view($id = null) {
-
 
121
		$searchableSubCategories = array('20', '8^20^15');
121
		$userId = $this->request->query('user_id');
122
		$userId = $this->request->query('user_id');
122
		
123
		
123
		if(isset($userId) && !empty($userId)) {
124
		if(isset($userId) && !empty($userId)) {
124
			$this->loadModel('User');
125
			$this->loadModel('User');
125
			$dbuser = $this->User->findById($userId);
126
			$dbuser = $this->User->findById($userId);
Line 263... Line 264...
263
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
264
				$errorstr = 'Oops!! Some Error Occured. <br> Please try after Some Time';
264
			}
265
			}
265
 
266
 
266
			
267
			
267
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
268
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
268
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr','nexturl','searchfor'));
269
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen','errorstr','nexturl','searchfor', 'searchableSubCategories'));
269
		}else{
270
		}else{
270
			//Check for apk support of sharing
271
			//Check for apk support of sharing
271
			$sharable = 0;
272
			$sharable = 0;
272
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
273
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
273
				$sharable = 1;
274
				$sharable = 1;
Line 410... Line 411...
410
 
411
 
411
	public function getdealsforsearchterm($searchterm,$page = null){
412
	public function getdealsforsearchterm($searchterm,$page = null){
412
		$likedDeals = $disLikedDeals = array();
413
		$likedDeals = $disLikedDeals = array();
413
		$this->layout = 'ajax';
414
		$this->layout = 'ajax';
414
		$page = $this->request->query('page');
415
		$page = $this->request->query('page');
415
		$brandschosen = $_COOKIE['brandschosen'];	 
-
 
416
		$subcategorieschosen = $_COOKIE['subcategorieschosen']; 
416
		$subcategorieschosen = $_COOKIE['subcategorieschosen']; 
417
		if(!isset($page)){
417
		if(!isset($page)){
418
			$page = 1;
418
			$page = 1;
419
			$offset = 0;
419
			$offset = 0;
420
			$limit=10;
420
			$limit=10;
421
			// $url= "http://45.79.106.95:8057/searchSubCategoryCount/?subCategoryId=".$subcategorieschosen."&searchTerm=".urlencode($searchterm);
-
 
422
			// $count = $this->make_request($url,null);
-
 
423
			// setcookie('countval', $count['count'], -1, '/');
-
 
424
		}
421
		}
425
		else{
422
		else{
426
			$offset = ($page*20) - 30;
423
			$offset = ($page*20) - 30;
427
			$limit = 20;
424
			$limit = 20;
428
		}
425
		}
429
		$sort = $this->request->query('sort');
426
		$sort = $this->request->query('sort');
430
		$direction = $this->request->query('direction');
427
		$direction = $this->request->query('direction');
431
		if(!empty($brandschosen) && !empty($subcategorieschosen)){
-
 
432
			$filter = 'brand|subcategory';
-
 
433
		}			
-
 
434
		else if(!empty($brandschosen) && empty($subcategorieschosen)){
-
 
435
			$filter = 'brand';
-
 
436
		}
-
 
437
		if(!empty($subcategorieschosen) && empty($brandschosen)){
-
 
438
			$filter = 'subcategory';
-
 
439
		}
-
 
440
 
428
 
441
		$brands = str_replace(',', '^', $brandschosen);
-
 
442
		$subcategories = str_replace(',', '^', $subcategorieschosen);
-
 
443
		$url = "http://45.79.106.95:8057/searchSubCategory/?offset=".$offset."&limit=".$limit."&searchTerm=".urlencode($searchterm)."&subCategoryId=".$subcategorieschosen;
429
		$url = $this->apihost."searchSubCategory/?offset=".$offset."&limit=".$limit."&searchTerm=".urlencode($searchterm)."&subCategoryId=".$subcategorieschosen;
444
		$response = $this->make_request($url,null);
430
		$response = $this->make_request($url,null);
445
		$deals = array();
431
		$deals = array();
446
		if(!empty($response)){
432
		if(!empty($response)){
447
			foreach ($response as $key => $value) {
433
			foreach ($response as $key => $value) {
448
				if(!empty($value)){
434
				if(!empty($value)){
449
					$deals[] = $value;
435
					$deals[] = $value;
450
				}
436
				}
451
			}
437
			}
452
		}
438
		}
453
		// if (!$this->Category->exists($id)) {
-
 
454
			// throw new NotFoundException(__('Invalid category'));
-
 
455
		// }
439
 
456
		$this->loadModel('Api');
440
		$this->loadModel('Api');
457
		// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
-
 
458
		// $deals = $apideals['products'];
-
 
-
 
441
 
459
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
442
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
460
		if(!empty($myactions)) {
443
		if(!empty($myactions)) {
461
			foreach ($myactions['actions'] as $key => $value) {
444
			foreach ($myactions['actions'] as $key => $value) {
462
				if($value['UserAction']['action'] == 'like'){
445
				if($value['UserAction']['action'] == 'like'){
463
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
446
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];