| 15697 |
anikendra |
1 |
<?php
|
| 15767 |
anikendra |
2 |
ini_set('display_errors', '0'); # don't show any errors...
|
|
|
3 |
error_reporting(E_ALL ^ E_STRICT); # ...but do log them
|
|
|
4 |
|
| 15697 |
anikendra |
5 |
class ClickInfoShell extends AppShell {
|
|
|
6 |
public $uses = array('MasterData','Click');
|
|
|
7 |
var $map = array();
|
|
|
8 |
|
|
|
9 |
public function main() {
|
|
|
10 |
$params = array(
|
| 16293 |
manas |
11 |
'fields' => array('_id','brand','source_product_name','category_id'),
|
| 15697 |
anikendra |
12 |
'conditions' => array('source_id' => array('$ne' => 0)),
|
|
|
13 |
'order' => array('_id' => 1),
|
|
|
14 |
// 'limit' => 100,
|
|
|
15 |
);
|
|
|
16 |
$masterdata = $this->MasterData->find('all', $params);
|
|
|
17 |
|
|
|
18 |
foreach ($masterdata as $key => $value) {
|
| 16293 |
manas |
19 |
$map[$value['MasterData']['id']] = array('name'=>$value['MasterData']['source_product_name'],'brand'=>$value['MasterData']['brand'],'category_id'=>$value['MasterData']['category_id']);
|
| 15697 |
anikendra |
20 |
}
|
|
|
21 |
$this->updateclicks($map);
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public function updateclicks($map) {
|
| 15767 |
anikendra |
25 |
$limit = 500;
|
| 15697 |
anikendra |
26 |
$params = array(
|
|
|
27 |
'fields' => array('id','store_product_id'),
|
| 15767 |
anikendra |
28 |
'conditions' => array('extras NOT LIKE' => '%notification%','brand'=>null,'store_product_id !='=>0),
|
| 15697 |
anikendra |
29 |
'order' => array('id' => 'desc'),
|
|
|
30 |
'limit' => $limit,
|
|
|
31 |
);
|
|
|
32 |
$clicks = $this->Click->find('all', $params);
|
| 15767 |
anikendra |
33 |
//$this->out(print_r($clicks,1));
|
| 15697 |
anikendra |
34 |
if(!empty($clicks)) {
|
|
|
35 |
foreach ($clicks as $key => $value) {
|
| 16293 |
manas |
36 |
$sql = "UPDATE clicks SET brand = '".$map[$value['Click']['store_product_id']]['brand']."' , product_name = '".addslashes($map[$value['Click']['store_product_id']]['name'])."', category_id='".$map[$value['Click']['store_product_id']]['category_id']."' WHERE id = ".$value['Click']['id'];
|
| 15767 |
anikendra |
37 |
//$this->out(print_r($sql,1));
|
| 15697 |
anikendra |
38 |
$this->Click->query($sql);
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
}
|