Subversion Repositories SmartDukaan

Rev

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

Rev 14016 Rev 14098
Line 210... Line 210...
210
				$result[$key] = $skuMap[$lowestPriceSku];
210
				$result[$key] = $skuMap[$lowestPriceSku];
211
			}
211
			}
212
		}
212
		}
213
		return $result;
213
		return $result;
214
	}
214
	}
-
 
215
 
-
 
216
	public function admin_update(){
-
 
217
		$this->response->type('json');
-
 
218
		$this->layout = 'ajax';
-
 
219
		$data[$this->request->data['id']] = $this->request->data['value'];
-
 
220
		$data['oid'] = $this->request->data['oid'];
-
 
221
		// $data['class'] = $this->request->data['class'];
-
 
222
		if($this->modelClass == 'Exceptionalskudiscount') {
-
 
223
			$data['class'] = 'SkuDiscountInfo';	
-
 
224
		}elseif($this->modelClass == 'Skuscheme'){
-
 
225
			$data['class'] = 'SkuSchemeDetails';
-
 
226
		}else{
-
 
227
			$data['class'] = $this->modelClass;
-
 
228
		}		
-
 
229
		$data_string = json_encode($data,JSON_NUMERIC_CHECK);
-
 
230
		$ch = curl_init();
-
 
231
		$url = $this->apihost.'Catalog/updateCollection';
-
 
232
		$this->log("[url] $url",'api');
-
 
233
		$this->log("[fields] ".print_r($data_string,1),'api');
-
 
234
		curl_setopt($ch, CURLOPT_URL, $url);
-
 
235
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
 
236
		curl_setopt($ch, CURLOPT_POST, true);
-
 
237
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // note the PUT here
-
 
238
 
-
 
239
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
-
 
240
		curl_setopt($ch, CURLOPT_HEADER, true);
-
 
241
 
-
 
242
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
-
 
243
		    'Content-Type: application/json',                                                                                
-
 
244
		    'Content-Length: ' . strlen($data_string)                                                                       
-
 
245
		));       
-
 
246
 
-
 
247
		// execute the request
-
 
248
 
-
 
249
		$output = curl_exec($ch);
-
 
250
		$result = $this->request->data['value'];
-
 
251
		$this->log("[response] ".print_r($output,1),'api');
-
 
252
		curl_close($ch);
-
 
253
		$this->set(array(
-
 
254
		    'result' => $result,
-
 
255
		    '_serialize' => array('result')
-
 
256
		));
-
 
257
		$this->render('/Elements/json');
-
 
258
	}
215
}
259
}