Subversion Repositories SmartDukaan

Rev

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

Rev 18164 Rev 18168
Line 54... Line 54...
54
 */
54
 */
55
	public function add($userId=null,$storeProductId=null,$storeId=null) {
55
	public function add($userId=null,$storeProductId=null,$storeId=null) {
56
		session_write_close();
56
		session_write_close();
57
		if(!empty($userId) && !empty($storeProductId)){
57
		if(!empty($userId) && !empty($storeProductId)){
58
			$url = $this->request->query('url');
58
			$url = $this->request->query('url');
-
 
59
			$url1=$url;
59
			$available_price = $this->request->query('price');
60
			$available_price = $this->request->query('price');
60
			//Get StoreProduct Info
61
			//Get StoreProduct Info
61
			$this->loadModel('Store');
62
			$this->loadModel('Store');
62
			// $options = array('conditions'=>array('id'=>$storeProductId),'fields'=>array('source_id','available_price','url'),'recursive'=>-1);
63
			// $options = array('conditions'=>array('id'=>$storeProductId),'fields'=>array('source_id','available_price','url'),'recursive'=>-1);
63
			// $storeProduct = $this->StoreProduct->find('first',$options);
64
			// $storeProduct = $this->StoreProduct->find('first',$options);
Line 134... Line 135...
134
				}
135
				}
135
			}
136
			}
136
			$extras = array('store'=>$store['Store']['name']);
137
			$extras = array('store'=>$store['Store']['name']);
137
			$data = array('user_id'=>$userId,'store_product_id'=>$storeProductId,'price'=>$available_price,'tag'=>$tag,'url'=>$url,'extras'=>json_encode($extras));
138
			$data = array('user_id'=>$userId,'store_product_id'=>$storeProductId,'price'=>$available_price,'tag'=>$tag,'url'=>$url,'extras'=>json_encode($extras));
138
			$this->Click->create();
139
			$this->Click->create();
139
			$curl = $this->livepriceurl."!latestPriceById?id=$storeProductId&source_id=$storeId&url=".base64_encode($url);
140
			$curl = $this->livepriceurl."!latestPriceById?id=$storeProductId&source_id=$storeId&url=".base64_encode($url1);
140
			$response = $this->make_request($curl,null);
141
			$response = $this->make_request($curl,null);
141
			$this->log("live price response ".print_r($response,1),'api');
142
			$this->log("live price response ".print_r($response,1),'api');
142
			if ($this->Click->save($data)) {
143
			if ($this->Click->save($data)) {
143
				if($response['result']){
144
				if($response['result']){
144
					$result = array('success'=>true,'message'=> $response['message'],'type'=>'redirect','url'=>$url,'showmessage'=>1);
145
					$result = array('success'=>true,'message'=> $response['message'],'type'=>'redirect','url'=>$url,'showmessage'=>1);