| Line 27... |
Line 27... |
| 27 |
$dbuser = $this->User->findById($userId);
|
27 |
$dbuser = $this->User->findById($userId);
|
| 28 |
$this->Auth->login($dbuser['User']);
|
28 |
$this->Auth->login($dbuser['User']);
|
| 29 |
}
|
29 |
}
|
| 30 |
$this->layout = "innerpages";
|
30 |
$this->layout = "innerpages";
|
| 31 |
$this->UserAction->Behaviors->attach('Containable');
|
31 |
$this->UserAction->Behaviors->attach('Containable');
|
| 32 |
$contain = array('StoreProduct.title','StoreProduct.thumbnail','StoreProduct.mrp','StoreProduct.available_price','StoreProduct.tagline');
|
32 |
// $contain = array('StoreProduct.title','StoreProduct.thumbnail','StoreProduct.mrp','StoreProduct.available_price','StoreProduct.tagline');
|
| 33 |
$options = array('contain'=>$contain,'conditions'=>array('UserAction.user_id'=>$this->Auth->User('id'),'UserAction.action'=>'like'));
|
33 |
$options = array('recursive'=>-1,'conditions'=>array('UserAction.user_id'=>$this->Auth->User('id'),'UserAction.action'=>'like'));
|
| 34 |
$myfavorites = $this->UserAction->find('all',$options);
|
34 |
$myfavorites = $this->UserAction->find('all',$options);
|
| - |
|
35 |
if(!empty($myfavorites)){
|
| - |
|
36 |
foreach ($myfavorites as $key => $value) {
|
| - |
|
37 |
$cachekey = 'storeproduct-'.$value['UserAction']['store_product_id'];
|
| - |
|
38 |
$product = Cache::read($cachekey,'fivemin');
|
| - |
|
39 |
if(empty($product)) {
|
| - |
|
40 |
$url = $this->apihost.'masterData/getSkuById/'.$value['UserAction']['store_product_id'];
|
| - |
|
41 |
$product = $this->make_request($url,null);
|
| - |
|
42 |
Cache::write($cachekey,$product,'fivemin');
|
| - |
|
43 |
}
|
| - |
|
44 |
$myfavorites[$key]['StoreProduct'] = json_decode($product[0],1);
|
| - |
|
45 |
}
|
| - |
|
46 |
}
|
| 35 |
$this->set(compact('myfavorites'));
|
47 |
$this->set(compact('myfavorites'));
|
| 36 |
}
|
48 |
}
|
| 37 |
|
49 |
|
| 38 |
public function update($user_id,$store_product_id,$action) {
|
50 |
public function update($user_id,$store_product_id,$action) {
|
| 39 |
if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
|
51 |
if(!empty($user_id) && !empty($store_product_id) && !empty($action)) {
|