function sync_tagging()
 {
     //        pr($_POST);
     LL_Tagging::convertToTree();
 }
 function tagging()
 {
     $LL = new LL_Tagging();
     //$LL->printColumlistAsAttributes();
     if ($_GET['truncate']) {
         $LL->truncate();
     }
     //        $url = "http://192.168.0.86:8880/goldwebapi/ecommerce/tagging";
     //        $url = "http://192.168.0.86:8180/goldwebapi/ecommerce/tagging";
     $url = $this->ip_address . "GOLDEcomm/Tagging";
     $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);
     $counter = 0;
     $yangdisave = 0;
     foreach ($data as $ro) {
         $ll = new LL_Tagging();
         $ll->fill($ro);
         //pr($ll);
         $ll->reltag_id = $ro['TaggingLevel1ID'] . "_" . $ro['TaggingLevel2ID'] . "_" . $ro['TaggingLevel3ID'];
         if ($ll->save()) {
             echo $ll->reltag_id . "<br>";
             $yangdisave++;
         }
         $counter++;
     }
     echo "Jumlah yang di crawl : " . $counter . "<br>";
     echo "Jumlah yang di save : " . $yangdisave . "<br>";
 }
 public function getCategory()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $ll = new LL_Tagging();
     $arr = $ll->getOrderBy("TaggingLevel1Order ASC, TaggingLevel2Order ASC, TaggingLevel3Order ASC");
     //pr($arr);
     $obj = $ll;
     if (count($arr) < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "Not Found";
         echo json_encode($json);
         die;
     }
     $sudah = array();
     $detail = array();
     $urutan = array();
     //saveYg1stLevelSama
     foreach ($arr as $obj) {
         $sudah[$obj->TaggingLevel1ID][$obj->TaggingLevel2ID][] = $obj->TaggingLevel3ID;
         $detail[$obj->TaggingLevel1ID] = $obj->TaggingLevel1Name;
         $detail[$obj->TaggingLevel2ID] = $obj->TaggingLevel2Name;
         $detail[$obj->TaggingLevel3ID] = $obj->TaggingLevel3Name;
         $urutan[$obj->TaggingLevel1ID] = (int) $obj->TaggingLevel1Order;
         $urutan[$obj->TaggingLevel2ID] = (int) $obj->TaggingLevel2Order;
         $urutan[$obj->TaggingLevel3ID] = (int) $obj->TaggingLevel3Order;
     }
     $json = array();
     $json['status_code'] = 1;
     $json['layer'] = $sudah;
     $json['detail'] = $detail;
     $json['urutan'] = $urutan;
     if (count($arr) < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Elements Found";
     }
     echo json_encode($json);
     die;
 }