Subversion Repositories SmartDukaan

Rev

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

Rev 13808 Rev 13815
Line 21... Line 21...
21
		$this->Auth->allow('bycategory','category','mine','getdeals');
21
		$this->Auth->allow('bycategory','category','mine','getdeals');
22
		$callback = $this->request->query('callback');		
22
		$callback = $this->request->query('callback');		
23
	}
23
	}
24
 
24
 
25
	public function search() {
25
	public function search() {
-
 
26
		$this->layout = 'innerpages';
26
		$q = $this->request->query('q');
27
		$q = $this->request->query('q');
27
		if(isset($q) && !empty($q)){
28
		if(isset($q) && !empty($q)){
-
 
29
			if (Configure::read('log_solr_queries') === true) {
-
 
30
				$this->loadModel('SearchTerm');
-
 
31
				$data = array('user_id' => $this->Auth->User('id'),'search_term' => $q);
-
 
32
				$this->SearchTerm->create();
-
 
33
				$this->SearchTerm->save($data);					
-
 
34
			}
28
			//Handle with solr
35
			//Handle with solr
-
 
36
			$cond = "q=$q";
-
 
37
		 	$sort = "store desc";
-
 
38
 
-
 
39
			$params = array(
-
 
40
				'conditions' =>array(
-
 
41
			 	'solr_query' => $cond
-
 
42
		 	),
-
 
43
			 	'order' => $sort,
-
 
44
			 	'offset' => 0,
-
 
45
			 	'limit' => 20
-
 
46
		 	);
-
 
47
			$this->loadModel('Solr');
-
 
48
			$result = $this->Solr->find('all', $params);
-
 
49
			// debug($result);
-
 
50
			$this->set(compact('result','q'));
29
		}
51
		}
30
	}
52
	}
31
 
53
 
32
	public function mine() {		
54
	public function mine() {		
33
		$userId = $this->request->query('user_id');
55
		$userId = $this->request->query('user_id');
Line 46... Line 68...
46
		//Sort and Direction
68
		//Sort and Direction
47
		$sort = $this->request->query('sort');
69
		$sort = $this->request->query('sort');
48
		$direction = $this->request->query('direction');
70
		$direction = $this->request->query('direction');
49
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),0,$sort,$direction);		
71
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),0,$sort,$direction);		
50
		$deals = $this->make_request($url,null);
72
		$deals = $this->make_request($url,null);
51
		// debug($deals);
-
 
52
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
73
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
53
		if(!empty($myactions)) {
74
		if(!empty($myactions)) {
54
			foreach ($myactions['actions'] as $key => $value) {
75
			foreach ($myactions['actions'] as $key => $value) {
55
				if($value['UserAction']['action'] == 'like'){
76
				if($value['UserAction']['action'] == 'like'){
56
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
77
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
Line 71... Line 92...
71
		$this->loadModel('Api');
92
		$this->loadModel('Api');
72
		$page = $this->request->query('page');
93
		$page = $this->request->query('page');
73
		if(!isset($page)){
94
		if(!isset($page)){
74
			$page = 1;
95
			$page = 1;
75
		}	
96
		}	
-
 
97
		//Sort and Direction
76
		// $apideals = $this->Api->getDeals($this->Auth->User('id'),$page);
98
		$sort = $this->request->query('sort');
77
		// $deals = $apideals['products'];
99
		$direction = $this->request->query('direction');
78
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),0,$sort,$direction);
100
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),0,$sort,$direction);
79
		$deals = $this->make_request($url,null);
101
		$deals = $this->make_request($url,null);
80
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
102
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
81
		if(!empty($myactions)) {
103
		if(!empty($myactions)) {
82
			foreach ($myactions['actions'] as $key => $value) {
104
			foreach ($myactions['actions'] as $key => $value) {