Subversion Repositories SmartDukaan

Rev

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

Rev 17979 Rev 19325
Line 34... Line 34...
34
		$this->set(compact('brands','categoryId'));
34
		$this->set(compact('brands','categoryId'));
35
	}
35
	}
36
 
36
 
37
	public function subcategoryfilter($type='subcategory',$categoryId=6){
37
	public function subcategoryfilter($type='subcategory',$categoryId=6){
38
		$url = $this->apihost.'deals/subCategory/?category_id='.$categoryId;
38
		$url = $this->apihost.'deals/subCategory/?category_id='.$categoryId;
-
 
39
        //debug($url);
39
		$brands = $this->make_request($url,null);
40
		$brands = $this->make_request($url,null);
40
		debug($brands);
41
		// debug($brands);
41
		$this->layout = 'innerpages';
42
		$this->layout = 'innerpages';
42
		$this->set(compact('brands','categoryId'));
43
		$this->set(compact('brands','categoryId'));
43
	}	
44
	}	
44
 
45
 
45
	public function search() {
46
	public function search() {
Line 65... Line 66...
65
				$data = array('user_id' => $this->Auth->User('id'),'search_term' => $q);
66
				$data = array('user_id' => $this->Auth->User('id'),'search_term' => $q);
66
				$this->SearchTerm->create();
67
				$this->SearchTerm->create();
67
				$this->SearchTerm->save($data);					
68
				$this->SearchTerm->save($data);					
68
			}
69
			}
69
			$result = $this->get_solr_result($q,$page);
70
			$result = $this->get_solr_result($q,$page);
-
 
71
			//debug($result);
70
			$this->set(compact('result','q','page'));
72
			$this->set(compact('result','q','page'));
71
		}else{
73
		}else{
72
			$this->set(compact('campaigns'));
74
			$this->set(compact('campaigns'));
73
		}
75
		}
74
	}
76
	}
Line 284... Line 286...
284
				// debug($product);
286
				// debug($product);
285
				array_push($result['products'],$product);
287
				array_push($result['products'],$product);
286
			}
288
			}
287
			$products = json_decode(stripslashes(json_encode($products)));
289
			$products = json_decode(stripslashes(json_encode($products)));
288
			$result['success'] = true;
290
			$result['success'] = true;
-
 
291
			$subcat_id = $result['products'][0]['subCategoryId'];
-
 
292
			$cat_id = $result['products'][0]['category_id'];
-
 
293
			
-
 
294
			//check for offer start
-
 
295
			$user_id = $this->Auth->user('id');
-
 
296
			$cachekey = 'target-'.$user_id;
-
 
297
			$getoffer = Cache::read($cachekey,'target');
-
 
298
			
-
 
299
			$offertext = "";
-
 
300
			$offerresponse = "";
-
 
301
			if($result['products'][0]['source_id'] == 4){
-
 
302
				if($getoffer === false){
-
 
303
					$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
304
					$offerresponse = $this->make_request($offerurl,null);
-
 
305
					Cache::write($cachekey , $offerresponse ,'target');
-
 
306
					if(!empty($offerresponse)){
-
 
307
						$current_time = time();
-
 
308
						if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
309
							
-
 
310
							if( isset($offerresponse['categories_applicable']) && in_array( $cat_id ,$offerresponse['categories_applicable']) && isset($offerresponse['sub_categories_not_applicable']) && !in_array($subcat_id ,$offerresponse['sub_categories_not_applicable'])){
-
 
311
								$offertext = $offerresponse['offer_description'];
-
 
312
							}
-
 
313
						}
-
 
314
						
-
 
315
					}
-
 
316
				}else{
-
 
317
					if(!empty($getoffer)){
-
 
318
							$offerresponse = $getoffer;
-
 
319
							$current_time = time();
-
 
320
							if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
321
								
-
 
322
								if( isset($offerresponse['categories_applicable']) && in_array( $cat_id ,$offerresponse['categories_applicable']) && isset($offerresponse['sub_categories_not_applicable']) && !in_array($subcat_id ,$offerresponse['sub_categories_not_applicable'])){
-
 
323
									$offertext = $offerresponse['offer_description'];
-
 
324
								}
-
 
325
							}
-
 
326
							
-
 
327
						}
-
 
328
				}
-
 
329
			}	
-
 
330
			
-
 
331
			$result['offertext'] = $offertext;
-
 
332
			//check for offer end
-
 
333
			
289
			// $result['products'] = $products;
334
			// $result['products'] = $products;
290
		} else{
335
		} else{
291
			$result['success'] = false;
336
			$result['success'] = false;
292
		}
337
		}
293
		$this->response->type('json');
338
		$this->response->type('json');