public static function getCategoriesRoute($lang = array())
{
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$option = $app->input->get('option', '', 'string');
$view = $app->input->get('view', '', 'string');
$activeId = 0;
if (isset($active->id)) {
$activeId = $active->id;
}
$itemId = 0;
if ((int) $activeId > 0 && $option == 'com_phocacart' && $view == 'category') {
// 2) if there are two menu links, try to select the one active
$itemId = $activeId;
}
$needles = array('categories' => '');
//Create the link
$link = 'index.php?option=com_phocacart&view=categories';
if ($item = PhocacartRoute::_findItem($needles, 1, $lang)) {
if (isset($item->query['layout'])) {
$link .= '&layout=' . $item->query['layout'];
}
// $item->id should be a "categories view" and it should have preference to category view
// so first we check item->id then itemId
if (isset($item->id) && (int) $item->id > 0) {
$link .= '&Itemid=' . $item->id;
} else {
if ((int) $itemId > 0) {
$link .= '&Itemid=' . (int) $itemId;
}
}
}
return $link;
}