예제 #1
0
    $tag = new Tag();
    $tag->setSource($newModel);
    $tag->loadById($newId);
    if ($oldTags[$oldId]['main_tag_id']) {
        $oldParentId = $oldTags[$oldId]['main_tag_id'];
    } else {
        $oldParentId = $oldTags[$oldId]['parent_id'];
    }
    $parentTagId = false;
    if (isset($newTagMapping[$oldParentId])) {
        $parentTagId = $newTagMapping[$oldParentId];
    }
    if (!$parentTagId) {
        $parentTagId = $rootTag->getId();
    }
    echo $oldParentId . "\t" . $parentTagId . "\t" . $oldTags[$oldId]['keyword'] . "\n";
    if ($oldTags[$oldId]['main_tag_id']) {
        $oldMasterTagId = $oldTags[$oldId]['main_tag_id'];
        $tag->setMasterTagId($newTagMapping[$oldMasterTagId]);
    }
    $tag->setParentId($parentTagId);
    $tag->update();
}
$startTime = microtime(true);
$tagTree = new Tag();
$tagTree->setSource($newModel);
$tagTree->reset();
$tagTree->buildTree();
$newModel->commit();
$elapsed = microtime(true) - $startTime;
echo "Tag tree building duration : " . $elapsed . "\n";