Subversion Repositories SmartDukaan

Rev

Rev 14509 | Rev 14539 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14098 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Exceptionalnlcs Controller
5
 *
6
 * @property Exceptionalnlc $Exceptionalnlc
7
 * @property PaginatorComponent $Paginator
8
 */
9
class MasterDatasController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
	public function beforeFilter() {
19
		parent::beforeFilter();
20
//		Configure::load('live');
21
		$this->apihost = Configure::read('pythonapihost');
22
	}
23
 
24
	public function admin_index() {
25
		$page = $this->request->query('page');
26
		if(!isset($page)){
27
			$page = 1;
28
		}
29
		$limit = Configure::read('admindashboardlimit');
30
		$params = array(
31
			'fields' => array('_id','brand','source_product_name', 'available_price', 'thumbnail','category','category_id','in_stock','marketPlaceUrl','mrp','rank','source_id','source_product_name','url'),
32
			'conditions' => array('source_id' => array('$ne' => 0)),
33
			'order' => array('_id' => -1),
34
			'limit' => $limit,
35
			'page' => $page,
36
		);
37
		$masterdata = $this->MasterData->find('all', $params);
38
		$this->loadModel('Category');
39
		$categories = $this->Category->find('list');
40
		$storemapping = Configure::read('storemapping');
41
		$this->set(compact('masterdata','categories','page','storemapping'));
42
	}
43
 
44
	public function admin_edit($id = null) {
45
		$id = (integer) $id;
46
		if (!$id && empty($this->data)) {
47
			$this->flash(__('Invalid Post', true), array('action' => 'index'));
48
		}
49
		if (!empty($this->data)) {
50
			if ($this->MasterData->save($this->data)) {
51
				$this->flash(__('The data has been saved.', true), array('action' => 'index'));
52
			} else {
53
			}
54
		}
55
		if (empty($this->data)) {
56
			$this->data = $this->MasterData->read(null, $id);
57
			debug($this->data);
58
		}
59
	}
14509 anikendra 60
 
61
	public function admin_search(){
62
		$page = $this->request->query('page');
63
		if(!isset($page)){
64
			$page = 1;
65
		}
66
		$limit = Configure::read('admindashboardlimit');
67
		$offset = ($page - 1)*$limit;
68
		$search = urlencode($this->request->query('search'));
69
		$url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
70
		$response = $this->make_request($url,null);
14517 anikendra 71
		$storemapping = Configure::read('storemapping');
14509 anikendra 72
		$this->set('masterdata', $response);
14517 anikendra 73
		$this->set(compact('page','search','storemapping'));
14509 anikendra 74
	}
14098 anikendra 75
}