| 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() {
|
| 14539 |
anikendra |
25 |
/*$page = $this->request->query('page');
|
| 14098 |
anikendra |
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');
|
| 14539 |
anikendra |
41 |
$this->set(compact('masterdata','categories','page','storemapping'));*/
|
|
|
42 |
$page = $this->request->query('page');
|
|
|
43 |
if(!isset($page)){
|
|
|
44 |
$page = 1;
|
|
|
45 |
}
|
|
|
46 |
$limit = Configure::read('admindashboardlimit');
|
|
|
47 |
$offset = ($page - 1)*$limit;
|
|
|
48 |
$search = '';
|
|
|
49 |
$url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
|
|
|
50 |
$response = $this->make_request($url,null);
|
|
|
51 |
$storemapping = Configure::read('storemapping');
|
|
|
52 |
$this->set('masterdata', $response);
|
|
|
53 |
$this->set(compact('page','search','storemapping'));
|
| 14098 |
anikendra |
54 |
}
|
|
|
55 |
|
|
|
56 |
public function admin_edit($id = null) {
|
|
|
57 |
$id = (integer) $id;
|
|
|
58 |
if (!$id && empty($this->data)) {
|
|
|
59 |
$this->flash(__('Invalid Post', true), array('action' => 'index'));
|
|
|
60 |
}
|
|
|
61 |
if (!empty($this->data)) {
|
|
|
62 |
if ($this->MasterData->save($this->data)) {
|
|
|
63 |
$this->flash(__('The data has been saved.', true), array('action' => 'index'));
|
|
|
64 |
} else {
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
if (empty($this->data)) {
|
|
|
68 |
$this->data = $this->MasterData->read(null, $id);
|
|
|
69 |
debug($this->data);
|
|
|
70 |
}
|
|
|
71 |
}
|
| 14509 |
anikendra |
72 |
|
|
|
73 |
public function admin_search(){
|
|
|
74 |
$page = $this->request->query('page');
|
|
|
75 |
if(!isset($page)){
|
|
|
76 |
$page = 1;
|
|
|
77 |
}
|
|
|
78 |
$limit = Configure::read('admindashboardlimit');
|
|
|
79 |
$offset = ($page - 1)*$limit;
|
|
|
80 |
$search = urlencode($this->request->query('search'));
|
|
|
81 |
$url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
|
|
|
82 |
$response = $this->make_request($url,null);
|
| 14517 |
anikendra |
83 |
$storemapping = Configure::read('storemapping');
|
| 14509 |
anikendra |
84 |
$this->set('masterdata', $response);
|
| 14517 |
anikendra |
85 |
$this->set(compact('page','search','storemapping'));
|
| 14509 |
anikendra |
86 |
}
|
| 14098 |
anikendra |
87 |
}
|