| Line 20... |
Line 20... |
| 20 |
$this->Auth->allow('bycategory','category');
|
20 |
$this->Auth->allow('bycategory','category');
|
| 21 |
$callback = $this->request->query('callback');
|
21 |
$callback = $this->request->query('callback');
|
| 22 |
}
|
22 |
}
|
| 23 |
|
23 |
|
| 24 |
public function mine() {
|
24 |
public function mine() {
|
| - |
|
25 |
$likedDeals = $disLikedDeals = array();
|
| 25 |
$this->loadModel('Api');
|
26 |
$this->loadModel('Api');
|
| 26 |
$page = $this->request->query('page');
|
27 |
$page = $this->request->query('page');
|
| 27 |
if(!isset($page)){
|
28 |
if(!isset($page)){
|
| 28 |
$page = 1;
|
29 |
$page = 1;
|
| 29 |
}
|
30 |
}
|
| 30 |
$title_for_layout = "Get Cashback on favourite";
|
31 |
$title_for_layout = "Get Cashback on favourite";
|
| 31 |
$description = "Get cashback on your favourite products.Mouth watering deals";
|
32 |
$description = "Get cashback on your favourite products.Mouth watering deals";
|
| 32 |
$apideals = $this->Api->getDeals();
|
33 |
$apideals = $this->Api->getDeals($this->Auth->User('id'));
|
| 33 |
$deals = $apideals['products'];
|
34 |
$deals = $apideals['products'];
|
| - |
|
35 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| - |
|
36 |
if(!empty($myactions)) {
|
| - |
|
37 |
foreach ($myactions['actions'] as $key => $value) {
|
| - |
|
38 |
if($value['UserAction']['action'] == 'like'){
|
| - |
|
39 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| - |
|
40 |
}else{
|
| - |
|
41 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| - |
|
42 |
}
|
| - |
|
43 |
}
|
| - |
|
44 |
}
|
| 34 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals'));
|
45 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
| 35 |
$this->render('/Pages/home');
|
46 |
$this->render('/Pages/home');
|
| 36 |
}
|
47 |
}
|
| 37 |
|
48 |
|
| 38 |
public function getdeals() {
|
49 |
public function getdeals() {
|
| - |
|
50 |
$likedDeals = $disLikedDeals = array();
|
| 39 |
$this->layout = 'ajax';
|
51 |
$this->layout = 'ajax';
|
| 40 |
$this->loadModel('Api');
|
52 |
$this->loadModel('Api');
|
| 41 |
$page = $this->request->query('page');
|
53 |
$page = $this->request->query('page');
|
| 42 |
if(!isset($page)){
|
54 |
if(!isset($page)){
|
| 43 |
$page = 1;
|
55 |
$page = 1;
|
| 44 |
}
|
56 |
}
|
| 45 |
$title_for_layout = "Get Cashback on favourite";
|
57 |
$title_for_layout = "Get Cashback on favourite";
|
| 46 |
$description = "Get cashback on your favourite products.Mouth watering deals";
|
58 |
$description = "Get cashback on your favourite products.Mouth watering deals";
|
| 47 |
$apideals = $this->Api->getDeals($this->Auth->User('id'),$page);
|
59 |
$apideals = $this->Api->getDeals($this->Auth->User('id'),$page);
|
| 48 |
$deals = $apideals['products'];
|
60 |
$deals = $apideals['products'];
|
| - |
|
61 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| - |
|
62 |
if(!empty($myactions)) {
|
| - |
|
63 |
foreach ($myactions['actions'] as $key => $value) {
|
| - |
|
64 |
if($value['UserAction']['action'] == 'like'){
|
| - |
|
65 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| - |
|
66 |
}else{
|
| - |
|
67 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| - |
|
68 |
}
|
| - |
|
69 |
}
|
| - |
|
70 |
}
|
| 49 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals'));
|
71 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
| 50 |
$this->render('/Elements/deals');
|
72 |
$this->render('/Elements/deals');
|
| 51 |
}
|
73 |
}
|
| 52 |
/**
|
74 |
/**
|
| 53 |
* index method
|
75 |
* index method
|
| 54 |
*
|
76 |
*
|
| Line 78... |
Line 100... |
| 78 |
$limit = 20;
|
100 |
$limit = 20;
|
| 79 |
$this->StoreProduct->recursive = -1;
|
101 |
$this->StoreProduct->recursive = -1;
|
| 80 |
// $count = $this->StoreProduct->find('count');
|
102 |
// $count = $this->StoreProduct->find('count');
|
| 81 |
$this->StoreProduct->Behaviors->attach('Containable');
|
103 |
$this->StoreProduct->Behaviors->attach('Containable');
|
| 82 |
$this->Paginator->settings = array('conditions'=>array('Product.category_id'=>$categoryId),'contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.price','StoreProduct.cashback','StoreProduct.available_price'));
|
104 |
$this->Paginator->settings = array('conditions'=>array('Product.category_id'=>$categoryId),'contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.price','StoreProduct.cashback','StoreProduct.available_price'));
|
| 83 |
$result = array('products' => $this->Paginator->paginate(),'maxresults'=>ceil($count/$limit));
|
105 |
$result = array('products' => $this->Paginator->paginate());
|
| 84 |
$callback = $this->request->query('callback');
|
106 |
$callback = $this->request->query('callback');
|
| 85 |
$this->set(array(
|
107 |
$this->set(array(
|
| 86 |
'result' => $result,
|
108 |
'result' => $result,
|
| 87 |
'callback' => $callback,
|
109 |
'callback' => $callback,
|
| 88 |
'_serialize' => array('result')
|
110 |
'_serialize' => array('result')
|