Subversion Repositories SmartDukaan

Rev

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

Rev 13759 Rev 13926
Line 26... Line 26...
26
		$this->layout = 'ajax';
26
		$this->layout = 'ajax';
27
		$userId = $this->request->query('user_id');
27
		$userId = $this->request->query('user_id');
28
		$productId = $this->request->query('product_id');
28
		$productId = $this->request->query('product_id');
29
		$hide = $this->request->query('hide');
29
		$hide = $this->request->query('hide');
30
		if(isset($hide) && !empty($hide) && $hide == 1){
30
		if(isset($hide) && !empty($hide) && $hide == 1){
31
			$this->loadModel('StoreProduct');
31
			// $this->loadModel('StoreProduct');
32
			$options = array('conditions'=>array('id'=>$productId),'fields'=>array('category_id','brand'),'recursive'=>-1);
32
			// $options = array('conditions'=>array('id'=>$productId),'fields'=>array('category_id','brand'),'recursive'=>-1);
33
			$product = $this->StoreProduct->find('first',$options);
33
			// $product = $this->StoreProduct->find('first',$options);
-
 
34
			$cachekey = 'storeproduct-'.$productId;
-
 
35
			$product = Cache::read($cachekey,'month');
-
 
36
			if(empty($product)) {
-
 
37
				$url = $this->apihost.'masterData/getSkuById/'.$productId;
-
 
38
				$productarr = $this->make_request($url,null);
-
 
39
				$product = json_decode($productarr[0],1);
-
 
40
				Cache::write($cachekey,$product,'month');			
-
 
41
			}	
34
			$this->loadModel('BrandPreference');
42
			$this->loadModel('BrandPreference');
35
			$data = array('user_id' => $userId, 'category_id' => $product['StoreProduct']['category_id'],'brand'=>$product['StoreProduct']['brand'],'status'=>'hide');
43
			$data = array('user_id' => $userId, 'category_id' => $product['category_id'],'brand'=>$product['brand'],'status'=>'hide');
-
 
44
			try{
36
			$this->BrandPreference->create();
45
				$this->BrandPreference->create();
37
			if($this->BrandPreference->save($data)){
46
				if($this->BrandPreference->save($data)){
38
				$result = array('success'=>true,'message'=>'brand hidden');
47
					$result = array('success'=>true,'message'=>'brand hidden');
39
			}else{
48
				}else{
40
				$result = array('success'=>false,'message'=>'database issue');
49
					$result = array('success'=>false,'message'=>'database issue');
-
 
50
				}
-
 
51
			}catch(exception $ex){
-
 
52
				$result = array('success'=>true,'message'=>$ex->getMessage());
41
			}
53
			}
42
		}else{
54
		}else{
43
			$result = array('success'=>false,'message'=>'brand not hidden');
55
			$result = array('success'=>false,'message'=>'brand not hidden');
44
		}
56
		}
45
		// $callback = $this->request->query('callback');
57
		// $callback = $this->request->query('callback');