Back to PhocacartRoute class

Method getCategoryRouteByTag

public static
getCategoryRouteByTag
(mixed $tagId)

Method getCategoryRouteByTag - Source code

public static function getCategoryRouteByTag($tagId)
{
    $app = Factory::getApplication();
    $menu = $app->getMenu();
    $active = $menu->getActive();
    $option = $app->input->get('option', '', 'string');
    $activeId = 0;
    if (isset($active->id)) {
        $activeId = $active->id;
    }
    if ((int) $activeId > 0 && $option == 'com_phocacart') {
        $needles = array('category' => '', 'categories' => (int) $activeId);
    } else {
        $needles = array('category' => '', 'categories' => '');
    }
    $db = Factory::getDBO();
    $query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' . ' FROM #__phocacart_tags AS a' . ' WHERE a.id = ' . (int) $tagId . ' ORDER BY a.id';
    $db->setQuery($query, 0, 1);
    $tag = $db->loadObject();
    if (isset($tag->id)) {
        $link = 'index.php?option=com_phocacart&view=category&id=tag&tagid=' . (int) $tag->id;
    } else {
        $link = 'index.php?option=com_phocacart&view=category&id=tag&tagid=0';
    }
    return self::_buildLink($link, $needles);
}