| Line 42... |
Line 42... |
| 42 |
Cache::write($cachekey,$product,'fivemin');
|
42 |
Cache::write($cachekey,$product,'fivemin');
|
| 43 |
}
|
43 |
}
|
| 44 |
$myfavorites[$key]['StoreProduct'] = json_decode($product[0],1);
|
44 |
$myfavorites[$key]['StoreProduct'] = json_decode($product[0],1);
|
| 45 |
}
|
45 |
}
|
| 46 |
}
|
46 |
}
|
| - |
|
47 |
$options = array('recursive'=>-1,'conditions'=>array('UserAction.user_id'=>$this->Auth->User('id'),'UserAction.action'=>'dislike'));
|
| - |
|
48 |
// $options = array('recursive'=>-1,'conditions'=>array('UserAction.user_id'=>$this->Auth->User('id')));
|
| - |
|
49 |
$mydislikes = $this->UserAction->find('all',$options);
|
| - |
|
50 |
if(!empty($mydislikes)){
|
| - |
|
51 |
foreach ($mydislikes as $key => $value) {
|
| - |
|
52 |
$cachekey = 'storeproduct-'.$value['UserAction']['store_product_id'];
|
| - |
|
53 |
$product = Cache::read($cachekey,'fivemin');
|
| - |
|
54 |
if(empty($product)) {
|
| - |
|
55 |
$url = $this->apihost.'masterData/getSkuById/'.$value['UserAction']['store_product_id'];
|
| - |
|
56 |
$product = $this->make_request($url,null);
|
| - |
|
57 |
Cache::write($cachekey,$product,'fivemin');
|
| - |
|
58 |
}
|
| - |
|
59 |
$mydislikes[$key]['StoreProduct'] = json_decode($product[0],1);
|
| - |
|
60 |
}
|
| - |
|
61 |
}
|
| 47 |
$this->set(compact('myfavorites'));
|
62 |
$this->set(compact('myfavorites','mydislikes'));
|
| 48 |
}
|
63 |
}
|
| 49 |
|
64 |
|
| 50 |
public function update($user_id,$store_product_id,$action) {
|
65 |
public function update($user_id,$store_product_id,$action) {
|
| 51 |
if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
|
66 |
if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
|
| 52 |
$data = array('user_id'=>$user_id,'store_product_id'=>$store_product_id);
|
67 |
$data = array('user_id'=>$user_id,'store_product_id'=>$store_product_id);
|
| Line 107... |
Line 122... |
| 107 |
));
|
122 |
));
|
| 108 |
$this->render('/Elements/jsonp');
|
123 |
$this->render('/Elements/jsonp');
|
| 109 |
}
|
124 |
}
|
| 110 |
}
|
125 |
}
|
| 111 |
|
126 |
|
| 112 |
public function deleteallfavs($user_id) {
|
127 |
public function deleteallfavs($user_id,$type='like') {
|
| 113 |
if(!empty($user_id)) {
|
128 |
if(!empty($user_id)) {
|
| 114 |
$loggedInUserId = $this->Auth->User('id');
|
129 |
$loggedInUserId = $this->Auth->User('id');
|
| 115 |
if($user_id != $loggedInUserId){
|
130 |
if($user_id != $loggedInUserId){
|
| 116 |
$result = array('success'=>false,'message'=>(__('Unauthorized access. Try again later')));
|
131 |
$result = array('success'=>false,'message'=>(__('Unauthorized access. Try again later')));
|
| 117 |
} else {
|
132 |
} else {
|
| 118 |
$sql = "DELETE FROM user_actions WHERE user_id = $user_id";
|
133 |
$sql = "DELETE FROM user_actions WHERE user_id = $user_id AND action = '$type'";
|
| 119 |
$this->UserAction->query($sql);
|
134 |
$this->UserAction->query($sql);
|
| 120 |
$result = array('success'=>true,'message'=>(__('All favourite products have been removed.')));
|
135 |
$result = array('success'=>true,'message'=>(__('All favourite products have been removed.')));
|
| 121 |
}
|
136 |
}
|
| 122 |
$this->response->type('json');
|
137 |
$this->response->type('json');
|
| 123 |
$this->layout = 'ajax';
|
138 |
$this->layout = 'ajax';
|