function articleWImage() { //$LL = new LL_Article; //$LL->printColumlistAsAttributes(); $ll = new LL_Article_WImage(); if ($_GET['truncate']) { $ll->truncate(); } $ean2 = new LL_Article_EAN(); if ($_GET['truncate']) { $ean2->truncate(); } // $url = "http://192.168.0.86:8180/goldwebapi/ecommerce/article"; //$url = "http://192.168.0.86:8880/goldwebapi/ecommerce/article"; $url = $this->ip_address . "GOLDEcomm/Article"; $data = file_get_contents($url); $data = json_decode($data, true); // Turns it into an array, change the last argument to false to make it an ob //pr($data); //pr($data); $counter = 0; $yangdisave = 0; $eandisave = 0; $eandicrawl = 0; foreach ($data as $ro) { $ll = new LL_Article_WImage(); $ll->fill($ro); pr($ll); if ($ll->save()) { // echo $ll->VariantID."<br>"; // echo $ll->VariantEAN."<br>"; $yangdisave++; //split EAN ke table EAN $split = explode(";", $ll->VariantEAN); foreach ($split as $ee) { $eandicrawl++; // echo "ean : ".$ee." "; $ean = new LL_Article_EAN(); $ean->ean_id = $ee; $ean->var_id = $ll->VariantID; if ($ean->save()) { $eandisave++; } else { echo "eanfailed " . $ee . " <br>"; } // echo "<br>"; } } else { echo "gagal " . $ll->VariantID . "<br>"; } $counter++; } echo "Jumlah yang di crawl : " . $counter . "<br>"; echo "Jumlah yang di save : " . $yangdisave . "<br>"; echo "Jumlah EAN yang di crawl : " . $eandicrawl . "<br>"; echo "Jumlah EAN yang di save : " . $eandisave . "<br>"; }
public function scan() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $id = addslashes($_GET['id']); //$type = addslashes($_GET['type']); //if($id == "")die("no id"); if ($id == "" || $id < 1) { $json['status_code'] = 0; $json['status_message'] = "No ID"; echo json_encode($json); die; } $ean = new LL_Article_EAN(); $ean->getByID($id); if ($ean->var_id != "" && $ean->var_id > 0) { $ll = new LL_Article_WImage(); $ll->getByID($ean->var_id); // $arr = $ll->getWhere("VariantINACode = '$id' LIMIT 0,1"); // $sel = $arr[0]; if ($ll->BaseArticleID != "") { $sel = $ll; $json['status_code'] = 1; //isi yang asli $obj2 = new LL_Article_WImage(); $exp2 = explode(",", $obj2->crud_webservice_allowed); $sem = array(); foreach ($exp2 as $attr2) { $sem[$attr2] = $sel->{$attr2}; } $json['results'] = $sem; //biar tidak hitung ulang if ($sel->ArticleType == 'Base') { $json['base'] = $sem; } else { //isi base $arrID = $sel->BaseArticleID; $arr2 = $ll->getWhere("BaseArticleID = '{$arrID}' AND ArticleType = 'Base' LIMIT 0,1"); $base = $arr2[0]; $sem2 = array(); foreach ($exp2 as $attr2) { $sem2[$attr2] = $base->{$attr2}; } $json['base'] = $sem2; } echo json_encode($json); die; } else { $json['status_code'] = 0; $json['status_message'] = "No Results found"; echo json_encode($json); die; } } else { $json['status_code'] = 0; $json['status_message'] = "No Results found"; echo json_encode($json); die; } }