Subversion Repositories SmartDukaan

Rev

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

Rev 14345 Rev 14386
Line 15... Line 15...
15
 *
15
 *
16
 * @var array
16
 * @var array
17
 */
17
 */
18
	public $components = array('Paginator');
18
	public $components = array('Paginator');
19
	public $apihost;	
19
	public $apihost;	
-
 
20
	public $livepriceurl;
20
 
21
 
21
	public function beforeFilter() {
22
	public function beforeFilter() {
22
		parent::beforeFilter();
23
		parent::beforeFilter();
23
		$this->Auth->allow('bycategory','category','mine','getdeals','getliveprice','search');
24
		$this->Auth->allow('bycategory','category','mine','getdeals','getliveprice','search');
24
		$callback = $this->request->query('callback');		
25
		$callback = $this->request->query('callback');	
-
 
26
		$this->livepriceurl = Configure::read('livepriceurl');	
25
	}
27
	}
26
 
28
 
27
	public function search() {
29
	public function search() {
28
		$userId = $this->request->query('user_id');
30
		$userId = $this->request->query('user_id');
29
		if(isset($userId) && !empty($userId)){
31
		if(isset($userId) && !empty($userId)){
Line 235... Line 237...
235
		$activestores = Configure::read('activestores');
237
		$activestores = Configure::read('activestores');
236
		$this->set(compact('storeProduct','activestores'));
238
		$this->set(compact('storeProduct','activestores'));
237
	}
239
	}
238
 
240
 
239
	public function getliveprice($bundleId=null,$storeId=null) {
241
	public function getliveprice($bundleId=null,$storeId=null) {
240
		$cachekey = 'liveprice-'.$bundleId.'-'.$storeId;
242
		// $cachekey = 'liveprice-'.$bundleId.'-'.$storeId;
241
		$this->log($cachekey,'api');
243
		// $this->log($cachekey,'api');
242
		// $products = Cache::read($cachekey,'fivemin');
244
		// $products = Cache::read($cachekey,'fivemin');
243
		if(empty($products)) {
245
		// if(empty($products)) {
244
			$result = array();
246
		$result = array();
245
			$this->response->type('json');
247
		$this->response->type('json');
246
			$this->layout = 'ajax';
248
		$this->layout = 'ajax';
247
			$url = $this->apihost."Catalog/fetchLivePrices/?skuBundleId=$bundleId&source_id=$storeId";
249
		$url = $this->livepriceurl."?skuBundleId=$bundleId&source_id=$storeId";
248
			$products = $this->make_request($url,null);
250
		$products = $this->make_request($url,null);
249
			Cache::write($cachekey,$products,'fivemin');			
251
			// Cache::write($cachekey,$products,'fivemin');			
250
		}
252
		// }
251
		if(!empty($products)){
253
		if(!empty($products)){
252
			$result['products'] = array();
254
			$result['products'] = array();
253
			foreach($products AS $product) {
255
			foreach($products AS $product) {
-
 
256
				// debug($product);
254
				array_push($result['products'],(json_decode($product)));
257
				array_push($result['products'],$product);
255
			}
258
			}
256
			$products = json_decode(stripslashes(json_encode($products)));
259
			$products = json_decode(stripslashes(json_encode($products)));
257
			$result['success'] = true;
260
			$result['success'] = true;
258
			// $result['products'] = $products;
261
			// $result['products'] = $products;
259
		}else{
262
		} else{
260
			$result['success'] = false;
263
			$result['success'] = false;
261
		}
264
		}
262
		$this->response->type('json');
265
		$this->response->type('json');
263
		$this->layout = 'ajax';
266
		$this->layout = 'ajax';
264
		$this->set(array(
267
		$this->set(array(