| Line 105... |
Line 105... |
| 105 |
$this->layout = 'ajax';
|
105 |
$this->layout = 'ajax';
|
| 106 |
$limit = 20;
|
106 |
$limit = 20;
|
| 107 |
$this->StoreProduct->recursive = -1;
|
107 |
$this->StoreProduct->recursive = -1;
|
| 108 |
// $count = $this->StoreProduct->find('count');
|
108 |
// $count = $this->StoreProduct->find('count');
|
| 109 |
$this->StoreProduct->Behaviors->attach('Containable');
|
109 |
$this->StoreProduct->Behaviors->attach('Containable');
|
| 110 |
$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.available_price','StoreProduct.cashback','StoreProduct.tagline','StoreProduct.offer','StoreProduct.available_price'));
|
110 |
$this->Paginator->settings = array('conditions'=>array('StoreProduct.category_id'=>$categoryId),'contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.available_price','StoreProduct.cashback','StoreProduct.tagline','StoreProduct.offer','StoreProduct.available_price'));
|
| 111 |
$result = array('products' => $this->Paginator->paginate());
|
111 |
$result = array('products' => $this->Paginator->paginate());
|
| 112 |
$callback = $this->request->query('callback');
|
112 |
$callback = $this->request->query('callback');
|
| 113 |
$this->set(array(
|
113 |
$this->set(array(
|
| 114 |
'result' => $result,
|
114 |
'result' => $result,
|
| 115 |
'callback' => $callback,
|
115 |
'callback' => $callback,
|
| Line 127... |
Line 127... |
| 127 |
$limit = 20;
|
127 |
$limit = 20;
|
| 128 |
$conditions = null;
|
128 |
$conditions = null;
|
| 129 |
$this->StoreProduct->recursive = -1;
|
129 |
$this->StoreProduct->recursive = -1;
|
| 130 |
$this->StoreProduct->Behaviors->attach('Containable');
|
130 |
$this->StoreProduct->Behaviors->attach('Containable');
|
| 131 |
$products = array();
|
131 |
$products = array();
|
| 132 |
if(!empty($userCategories)){
|
132 |
// if(!empty($userCategories)){
|
| - |
|
133 |
if(1==2){
|
| 133 |
foreach ($userCategories as $key => $value) {
|
134 |
foreach ($userCategories as $key => $value) {
|
| 134 |
$categoryIds[] = $value['UserCategory']['category_id'];
|
135 |
$categoryIds[] = $value['UserCategory']['category_id'];
|
| 135 |
$conditions = array('Product.category_id'=>$value['UserCategory']['category_id']);
|
136 |
$conditions = array('StoreProduct.category_id'=>$value['UserCategory']['category_id']);
|
| 136 |
$this->Paginator->settings = array('contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.available_price','StoreProduct.cashback','StoreProduct.available_price','StoreProduct.tagline','StoreProduct.offer'),'conditions'=>$conditions);
|
137 |
$this->Paginator->settings = array('contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.available_price','StoreProduct.cashback','StoreProduct.available_price','StoreProduct.tagline','StoreProduct.offer'),'conditions'=>$conditions);
|
| 137 |
$rows = $this->Paginator->paginate();
|
138 |
$rows = $this->Paginator->paginate();
|
| 138 |
foreach($rows AS $key => $product){
|
139 |
foreach($rows AS $key => $product){
|
| 139 |
$products[$value['UserCategory']['category_id']][$key][] = $product;
|
140 |
$products[$value['UserCategory']['category_id']][$key][] = $product;
|
| 140 |
}
|
141 |
}
|
| Line 142... |
Line 143... |
| 142 |
}else{
|
143 |
}else{
|
| 143 |
//Fetch all categories
|
144 |
//Fetch all categories
|
| 144 |
$categories = $this->StoreProduct->Product->Category->find('all');
|
145 |
$categories = $this->StoreProduct->Product->Category->find('all');
|
| 145 |
foreach ($categories as $key => $value) {
|
146 |
foreach ($categories as $key => $value) {
|
| 146 |
$categoryIds[] = $value['Category']['id'];
|
147 |
$categoryIds[] = $value['Category']['id'];
|
| 147 |
$conditions = array('Product.category_id'=>$value['Category']['id']);
|
148 |
$conditions = array('StoreProduct.category_id'=>$value['Category']['id']);
|
| 148 |
$this->Paginator->settings = array('contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.available_price','StoreProduct.cashback','StoreProduct.available_price','StoreProduct.tagline','StoreProduct.offer'),'conditions'=>$conditions);
|
149 |
$this->Paginator->settings = array('contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.available_price','StoreProduct.cashback','StoreProduct.available_price','StoreProduct.tagline','StoreProduct.offer'),'conditions'=>$conditions);
|
| 149 |
$rows = $this->Paginator->paginate();
|
150 |
$rows = $this->Paginator->paginate();
|
| 150 |
foreach($rows AS $key => $product){
|
151 |
foreach($rows AS $key => $product){
|
| 151 |
$products[$value['Category']['id']][$key][] = $product;
|
152 |
$products[$value['Category']['id']][$key][] = $product;
|
| 152 |
}
|
153 |
}
|
| 153 |
}
|
154 |
}
|
| 154 |
}
|
155 |
}
|
| - |
|
156 |
$this->log(print_r($products,1),'bycategory') ;
|
| 155 |
$result = array('products' => $products);//,'categories'=>$categoryIds);
|
157 |
$result = array('products' => $products);//,'categories'=>$categoryIds);
|
| 156 |
$callback = $this->request->query('callback');
|
158 |
$callback = $this->request->query('callback');
|
| 157 |
$this->set(array(
|
159 |
$this->set(array(
|
| 158 |
'result' => $result,
|
160 |
'result' => $result,
|
| 159 |
'callback' => $callback,
|
161 |
'callback' => $callback,
|