| Line 160... |
Line 160... |
| 160 |
if(!empty($date)){
|
160 |
if(!empty($date)){
|
| 161 |
$sql = "select count(*) as count,product_name,brand,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and date(created)='$date' group by store_product_id order by count desc";
|
161 |
$sql = "select count(*) as count,product_name,brand,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and date(created)='$date' group by store_product_id order by count desc";
|
| 162 |
} else{
|
162 |
} else{
|
| 163 |
$sql = "select count(*) as count,product_name,brand,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and date(created)=curdate() group by store_product_id order by count desc";
|
163 |
$sql = "select count(*) as count,product_name,brand,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and date(created)=curdate() group by store_product_id order by count desc";
|
| 164 |
}
|
164 |
}
|
| 165 |
$clicks_count = $this->Click->query($sql);
|
165 |
$clicks_count = $this->Click->query($sql);
|
| 166 |
$this->set(compact('clicks_count'));
|
166 |
$this->set(compact('clicks_count'));
|
| 167 |
}else{
|
167 |
}else{
|
| 168 |
$sql="select count(*) as count,date(created) date,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and product_name ='$product' group by date(created) order by date desc";
|
168 |
$sql="select count(*) as count,date(created) date,count(distinct user_id) as countUserId from clicks where length(product_name)>0 and store_product_id>0 and product_name ='$product' group by date(created) order by date desc";
|
| 169 |
$product_count = $this->Click->query($sql);
|
169 |
$product_count = $this->Click->query($sql);
|
| 170 |
$this->set(compact('product_count','product'));
|
170 |
$this->set(compact('product_count','product'));
|
| 171 |
}
|
171 |
}
|
| 172 |
}
|
172 |
}
|
| - |
|
173 |
|
| - |
|
174 |
public function admin_productviews_report($product=null) {
|
| - |
|
175 |
set_time_limit(180);
|
| - |
|
176 |
$this->loadModel('UserUrl');
|
| - |
|
177 |
$this->loadModel('MasterData');
|
| - |
|
178 |
$date = $this->request->query('date');
|
| - |
|
179 |
|
| - |
|
180 |
if($product==null || $product=='search'){
|
| - |
|
181 |
if(!empty($date)){
|
| - |
|
182 |
$sql = "SELECT DATE( created ) date, count(id) AS count,count(distinct user_id) as countUserId, SUBSTRING_INDEX( url, '/', -1 ) AS skuBundleId FROM `user_urls` WHERE date(created) = '$date' AND url LIKE '%store_products/view%' GROUP BY url ORDER BY count DESC ";
|
| - |
|
183 |
} else{
|
| - |
|
184 |
$sql = "SELECT DATE( created ) date, count(id) AS count,count(distinct user_id) as countUserId, SUBSTRING_INDEX( url, '/', -1 ) AS skuBundleId FROM `user_urls` WHERE date(created) = curdate() AND url LIKE '%store_products/view%' group by url ORDER BY count DESC ";
|
| - |
|
185 |
}
|
| - |
|
186 |
$clicks_count = $this->UserUrl->query($sql);
|
| - |
|
187 |
$this->set(compact('clicks_count'));
|
| - |
|
188 |
} else{
|
| - |
|
189 |
$sql = "SELECT DATE( created ) date, count(id) AS count,count(distinct user_id) as countUserId, SUBSTRING_INDEX( url, '/', -1 ) AS skuBundleId FROM `user_urls` WHERE SUBSTRING_INDEX( url, '/', -1 ) = $product group by date(created) ORDER BY id DESC ";
|
| - |
|
190 |
$product_count = $this->UserUrl->query($sql);
|
| - |
|
191 |
$this->set(compact('product_count','product'));
|
| - |
|
192 |
}
|
| - |
|
193 |
$params = array(
|
| - |
|
194 |
'fields' => array('skuBundleId','brand','source_product_name'),
|
| - |
|
195 |
'conditions' => array('source_id' => array('$ne' => 0)),
|
| - |
|
196 |
'order' => array('_id' => 1),
|
| - |
|
197 |
);
|
| - |
|
198 |
$masterdata = $this->MasterData->find('all', $params);
|
| - |
|
199 |
|
| - |
|
200 |
foreach ($masterdata as $key => $value) {
|
| - |
|
201 |
$map[$value['MasterData']['skuBundleId']] = array('name'=>$value['MasterData']['source_product_name'],'brand'=>$value['MasterData']['brand']);
|
| - |
|
202 |
}
|
| - |
|
203 |
$this->set(compact('map'));
|
| - |
|
204 |
}
|
| 173 |
}
|
205 |
}
|
| 174 |
|
206 |
|