Subversion Repositories SmartDukaan

Rev

Rev 15767 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15697 anikendra 1
<?php
2
class ClickInfoShell extends AppShell {
3
	public $uses = array('MasterData','Click');
4
	var $map = array();
5
 
6
	public function main() {
7
		$params = array(
8
			'fields' => array('_id','brand','source_product_name'),
9
			'conditions' => array('source_id' => array('$ne' => 0)),
10
			'order' => array('_id' => 1),
11
			// 'limit' => 100,
12
		);
13
		$masterdata = $this->MasterData->find('all', $params);
14
 
15
		foreach ($masterdata as $key => $value) {
16
			$map[$value['MasterData']['id']] = array('name'=>$value['MasterData']['source_product_name'],'brand'=>$value['MasterData']['brand']);
17
		}
18
		$this->updateclicks($map);
19
	}
20
 
21
	public function updateclicks($map) {
22
		$limit = 1000;
23
		$params = array(
24
			'fields' => array('id','store_product_id'),
25
			'conditions' => array('extras NOT LIKE' => 'notification','brand'=>null),
26
			'order' => array('id' => 'desc'),
27
			'limit' => $limit,
28
		);
29
		$clicks = $this->Click->find('all', $params);
30
		if(!empty($clicks)) {
31
			foreach ($clicks as $key => $value) {
32
				$sql = "UPDATE clicks SET brand = '".$map[$value['Click']['store_product_id']]['brand']."' , product_name = '".$map[$value['Click']['store_product_id']]['name']."' WHERE id = ".$value['Click']['id'];
33
				// $this->out($sql);
34
				$this->Click->query($sql);
35
			}
36
		}			
37
	}
38
}