Subversion Repositories SmartDukaan

Rev

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

Rev 13550 Rev 13567
Line 38... Line 38...
38
		$this->set(array(
38
		$this->set(array(
39
		    'result' => $result,
39
		    'result' => $result,
40
		    'callback' => $callback,
40
		    'callback' => $callback,
41
		    '_serialize' => array('result')
41
		    '_serialize' => array('result')
42
		));
42
		));
43
		$this->render('/Elements/jsonp');
43
		$this->render('/Elements/json');
44
	}
44
	}
45
 
45
 
46
	public function bycategory($userId=null) {
46
	public function bycategory($userId=null) {
47
		$this->loadModel('UserCategory');
47
		$this->loadModel('UserCategory');
48
		$options = array('conditions' => array('user_id'=>$userId),'recursive'=>-1);
48
		$options = array('conditions' => array('user_id'=>$userId),'recursive'=>-1);
Line 63... Line 63...
63
				$rows = $this->Paginator->paginate();				
63
				$rows = $this->Paginator->paginate();				
64
				foreach($rows AS $key => $product){
64
				foreach($rows AS $key => $product){
65
					$products[$value['UserCategory']['category_id']][$key][] = $product;
65
					$products[$value['UserCategory']['category_id']][$key][] = $product;
66
				}
66
				}
67
			}
67
			}
-
 
68
		}else{
-
 
69
			//Fetch all categories
-
 
70
			$categories = $this->StoreProduct->Product->Category->find('all');
-
 
71
			foreach ($categories as $key => $value) {
-
 
72
				$categoryIds[] = $value['Category']['id'];
-
 
73
				$conditions = array('Product.category_id'=>$value['Category']['id']);
-
 
74
				$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'),'conditions'=>$conditions);
-
 
75
				$rows = $this->Paginator->paginate();				
-
 
76
				foreach($rows AS $key => $product){
-
 
77
					$products[$value['Category']['id']][$key][] = $product;
-
 
78
				}
-
 
79
			}
68
		}				
80
		}				
69
		$result = array('products' => $products);//,'categories'=>$categoryIds);
81
		$result = array('products' => $products);//,'categories'=>$categoryIds);
70
		$callback = $this->request->query('callback');
82
		$callback = $this->request->query('callback');
71
		$this->set(array(
83
		$this->set(array(
72
		    'result' => $result,
84
		    'result' => $result,
73
		    'callback' => $callback,
85
		    'callback' => $callback,
74
		    '_serialize' => array('result')
86
		    '_serialize' => array('result')
75
		));
87
		));
76
		$this->render('/Elements/jsonp');
88
		$this->render('/Elements/json');
77
	}
89
	}
78
 
90
 
79
/**
91
/**
80
 * view method
92
 * view method
81
 *
93
 *