Subversion Repositories SmartDukaan

Rev

Rev 13570 | Rev 13583 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13570 Rev 13579
Line 15... Line 15...
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
18
	public function beforeFilter() {
18
	public function beforeFilter() {
19
		parent::beforeFilter();
19
		parent::beforeFilter();
20
		$this->Auth->allow('bycategory');
20
		$this->Auth->allow('bycategory','category');
21
		$callback = $this->request->query('callback');
21
		$callback = $this->request->query('callback');
22
	}
22
	}
23
 
23
 
24
	public function mine() {
24
	public function mine() {
25
		$this->loadModel('Api');
25
		$this->loadModel('Api');
Line 59... Line 59...
59
		$this->layout = 'ajax';
59
		$this->layout = 'ajax';
60
		$limit = 20;
60
		$limit = 20;
61
		$this->StoreProduct->recursive = -1;
61
		$this->StoreProduct->recursive = -1;
62
		$count = $this->StoreProduct->find('count');
62
		$count = $this->StoreProduct->find('count');
63
		$this->StoreProduct->Behaviors->attach('Containable');
63
		$this->StoreProduct->Behaviors->attach('Containable');
-
 
64
		$this->Paginator->settings = array('order'=>array('available_price'=>'desc'), 'contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.price','StoreProduct.cashback','StoreProduct.available_price'));
-
 
65
		$result = array('products' => $this->Paginator->paginate(),'maxresults'=>ceil($count/$limit));
-
 
66
		$callback = $this->request->query('callback');
-
 
67
		$this->set(array(
-
 
68
		    'result' => $result,
-
 
69
		    'callback' => $callback,
-
 
70
		    '_serialize' => array('result')
-
 
71
		));
-
 
72
		$this->render('/Elements/json');
-
 
73
	}
-
 
74
 
-
 
75
	public function category($user_id=null,$categoryId=null) {
-
 
76
		$this->response->type('json');
-
 
77
		$this->layout = 'ajax';
-
 
78
		$limit = 20;
-
 
79
		$this->StoreProduct->recursive = -1;
-
 
80
		// $count = $this->StoreProduct->find('count');
-
 
81
		$this->StoreProduct->Behaviors->attach('Containable');
64
		$this->Paginator->settings = array('contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.price','StoreProduct.cashback','StoreProduct.available_price'));
82
		$this->Paginator->settings = array('conditions'=>array('Product.category_id'=>$categoryId),'contain'=>array('Product'),'limit'=>$limit,'fields'=>array('Product.category_id','StoreProduct.id','StoreProduct.title','StoreProduct.thumbnail','StoreProduct.price','StoreProduct.cashback','StoreProduct.available_price'));
65
		$result = array('products' => $this->Paginator->paginate(),'maxresults'=>ceil($count/$limit));
83
		$result = array('products' => $this->Paginator->paginate(),'maxresults'=>ceil($count/$limit));
66
		$callback = $this->request->query('callback');
84
		$callback = $this->request->query('callback');
67
		$this->set(array(
85
		$this->set(array(
68
		    'result' => $result,
86
		    'result' => $result,
69
		    'callback' => $callback,
87
		    'callback' => $callback,