$contents = file_get_contents($url);
    $obj = json_decode($contents);
    $arrN = $obj->results;
    foreach ($arrN as $ss) {
        if (!in_array($ss->VariantID, $sudah)) {
            $sudah[] = $ss->VariantID;
            $sem[$ss->VariantID] = $ss;
        } else {
            $sem[$ss->VariantID]->TaggingLevel3ID .= " " . $ss->TaggingLevel3ID;
        }
    }
    \Leap\View\InputConditionTBS::printer($sem);
}
if ($action == "2") {
    $n = new \MProdModel();
    $m = new MArticleTagging();
    $z = new MProdCat();
    $mode = "all";
    if ($mode == "all") {
        $n->default_read_coloms = "*";
        $arrN = $n->getAll();
    } else {
        if ($mode == "filter1") {
            $arrN = $n->getWhereFromMultipleTable("{$n->table_name}.BaseArticleID = ecommultiple__articletagging.BaseArticleID", array("MArticleTagging"));
        } else {
            $arrN = $n->getWhereFromMultipleTable("{$n->table_name}.BaseArticleID = ecommultiple__articletagging.BaseArticleID AND ecommultiple__articletagging.TaggingLevel3ID = ecommultiple__product_category.cat_id", array("MArticleTagging", "MProdCat"));
        }
    }
    $sudah = array();
    $num = 0;
    $bisa = 0;
 function sync_articletagging()
 {
     $token = IMBAuth::createOAuth();
     $url = "http://localhost:8888/tbsecom/LLProdWeb/LL_ArticleTagging_wbase?cmd=ws&mws=getall&token=" . $token;
     //        echo $url;
     //        pr($_POST);
     $contents = file_get_contents($url);
     //        pr($contents);
     $obj = json_decode($contents);
     //        pr($obj);
     //        $nn = new MProdModel();
     //        global $db;
     //        $db->query("UPDATE {$nn->table_name} SET prod_active = 0",1);
     if ($_POST['radio'] == "truncate") {
         $nn = new MArticleTagging();
         $nn->truncate();
     }
     //        pr($obj);
     $num = 0;
     $gagal = 0;
     $gagalArr = array();
     foreach ($obj->results as $new) {
         $nn = new MArticleTagging();
         $nn->fill(toRow($new));
         //            $nn->prod_active = 1;
         if ($nn->save(1)) {
             $num++;
         } else {
             $gagal++;
             $gagalArr = $new->rel_id;
         }
     }
     $json['success'] = $num;
     $json['failed'] = $gagal;
     $json['failed_arr'] = $gagalArr;
     echo json_encode($json);
     die;
 }
 static function loadData()
 {
     $n = new MProdModel();
     $m = new MArticleTagging();
     $z = new MProdCat();
     $mode = "all";
     if ($mode == "all") {
         $n->default_read_coloms = "*";
         $arrN = $n->getAll();
     } else {
         if ($mode == "filter1") {
             $arrN = $n->getWhereFromMultipleTable("{$n->table_name}.BaseArticleID = ecommultiple__articletagging.BaseArticleID", array("MArticleTagging"));
         } else {
             $arrN = $n->getWhereFromMultipleTable("{$n->table_name}.BaseArticleID = ecommultiple__articletagging.BaseArticleID AND ecommultiple__articletagging.TaggingLevel3ID = ecommultiple__product_category.cat_id", array("MArticleTagging", "MProdCat"));
         }
     }
     $sudah = array();
     $num = 0;
     $bisa = 0;
     foreach ($arrN as $ss) {
         if (!in_array($ss->VariantID, $sudah)) {
             $sudah[] = $ss->VariantID;
             //            $arr = $z->getWhere("cat_id = '".$ss->TaggingLevel3ID."'");
             //            $ss->tagging = $arr;
             if ($mode == "all") {
                 $arr = $m->getWhere("BaseArticleID = '" . $ss->BaseArticleID . "'");
                 //                pr($arr);
                 if (count($arr) < 1) {
                     $ss->TaggingLevel3ID = "";
                     $num++;
                 } else {
                     $imp = array();
                     foreach ($arr as $sss) {
                         $imp[] = $sss->TaggingLevel3ID;
                     }
                     $bisa++;
                     $ss->TaggingLevel3ID = implode(" ", $imp);
                 }
             }
             $sem[$ss->VariantID] = $ss;
         }
         //            else {
         //                $sem[$ss->VariantID]->TaggingLevel3ID .= " " . $ss->TaggingLevel3ID;
         //            }
     }
 }