| Line 61... |
Line 61... |
| 61 |
$this->loadModel('Store');
|
61 |
$this->loadModel('Store');
|
| 62 |
// $options = array('conditions'=>array('id'=>$storeProductId),'fields'=>array('source_id','available_price','url'),'recursive'=>-1);
|
62 |
// $options = array('conditions'=>array('id'=>$storeProductId),'fields'=>array('source_id','available_price','url'),'recursive'=>-1);
|
| 63 |
// $storeProduct = $this->StoreProduct->find('first',$options);
|
63 |
// $storeProduct = $this->StoreProduct->find('first',$options);
|
| 64 |
$cachekey = 'storeproduct-'.$storeProductId;
|
64 |
$cachekey = 'storeproduct-'.$storeProductId;
|
| 65 |
|
65 |
|
| - |
|
66 |
$product = Cache::read($cachekey,'five');
|
| - |
|
67 |
if(empty($product)) {
|
| - |
|
68 |
$url = $this->apihost.'masterData/getSkuById/'.$storeProductId;
|
| - |
|
69 |
$product = $this->make_request($url,null);
|
| - |
|
70 |
Cache::write($cachekey,$product,'five');
|
| - |
|
71 |
}
|
| - |
|
72 |
$storeProduct = json_decode($product[0],1);
|
| - |
|
73 |
$storeProductName = $storeProduct['source_product_name'];
|
| - |
|
74 |
$storeProductBrand = $storeProduct['brand'];
|
| - |
|
75 |
$storeProductCategory = $storeProduct['category_id'];
|
| 66 |
if($url=='undefined' || $available_price=='undefined' || $storeId=='undefined') {
|
76 |
if($url=='undefined' || $available_price=='undefined' || $storeId=='undefined') {
|
| 67 |
$product = Cache::read($cachekey,'five');
|
- |
|
| 68 |
if(empty($product)) {
|
- |
|
| 69 |
$url = $this->apihost.'masterData/getSkuById/'.$storeProductId;
|
- |
|
| 70 |
$product = $this->make_request($url,null);
|
- |
|
| 71 |
Cache::write($cachekey,$product,'five');
|
- |
|
| 72 |
}
|
- |
|
| 73 |
$storeProduct = json_decode($product[0],1);
|
- |
|
| 74 |
$url = $storeProduct['marketPlaceUrl'];
|
77 |
$url = $storeProduct['marketPlaceUrl'];
|
| 75 |
$storeId = $storeProduct['source_id'];
|
78 |
$storeId = $storeProduct['source_id'];
|
| 76 |
$available_price = $storeProduct['available_price'];
|
79 |
$available_price = $storeProduct['available_price'];
|
| 77 |
}
|
80 |
}
|
| 78 |
$url1=$url;
|
81 |
$url1=$url;
|
| Line 139... |
Line 142... |
| 139 |
if(!empty($store['Store']['sub_tag_param'])){
|
142 |
if(!empty($store['Store']['sub_tag_param'])){
|
| 140 |
$url .= '&'.$store['Store']['sub_tag_param'].'='.$tag;
|
143 |
$url .= '&'.$store['Store']['sub_tag_param'].'='.$tag;
|
| 141 |
}
|
144 |
}
|
| 142 |
}
|
145 |
}
|
| 143 |
$extras = array('store'=>$store['Store']['name']);
|
146 |
$extras = array('store'=>$store['Store']['name']);
|
| 144 |
$data = array('user_id'=>$userId,'store_product_id'=>$storeProductId,'price'=>$available_price,'tag'=>$tag,'url'=>$url,'extras'=>json_encode($extras));
|
147 |
$data = array('user_id'=>$userId,'store_product_id'=>$storeProductId,'price'=>$available_price, 'product_name'=>$storeProductName, 'brand'=>$storeProductBrand, 'category'=>$storeProductCategory, 'tag'=>$tag,'url'=>$url,'extras'=>json_encode($extras));
|
| 145 |
$this->Click->create();
|
148 |
$this->Click->create();
|
| 146 |
$curl = $this->livepriceurl."!latestPriceById?id=$storeProductId&source_id=$storeId&url=".base64_encode($url1);
|
149 |
$curl = $this->livepriceurl."!latestPriceById?id=$storeProductId&source_id=$storeId&url=".base64_encode($url1);
|
| 147 |
$response = $this->make_request($curl,null);
|
150 |
$response = $this->make_request($curl,null);
|
| 148 |
$this->log("live price response ".print_r($response,1),'api');
|
151 |
$this->log("live price response ".print_r($response,1),'api');
|
| 149 |
if ($this->Click->save($data)) {
|
152 |
if ($this->Click->save($data)) {
|