Virtuemart Pathway – Why is it not working?

After installing Virtuemart, a highly integrated shopping cart for Joomla!, I realized that there was a small issue. The issue dealt with the way Virtuemart and Joomla! displayed the pathway of the cart. The product displayed a double pathway, and most of the links were not working. When you were browsing a category you couldn’t go back to the main store because the link was not linkable. This was very annoying to me. After hours of trying to figure out what was happening and going through code pieces, I finally put together bunch of various hacks. This is what ended up working for me. I successfully tested it on all versions of Joomla!, but only with Virtuemart 1.0.5.

Open up the following file in your favorite editor: /administrator/components/com_virtuemart/classes/ps_product_category.php

Find the following code:


setQuery($q);   $db->query();
    $db->next_record();
    if ($db->f("category_parent_id")) {
    $link = "<a class=""pathway"" href="">url($_SERVER['PHP_SELF'] . "?page=shop.browse&category_id=$category_id");
    $link .= "">";
    $link .= $db->f("category_name");
    $link .= "</a>";
    $category_list[$i++] = " ".$this->pathway_separator()." ". $link;
    $this->get_navigation_list($db->f("category_parent_id"));
    }
    else {
    $link = "<a class=""pathway"" href="">url($_SERVER['PHP_SELF'] . "?page=shop.browse&category_id=$category_id");
    $link .= "">";
    $link .= $db->f("category_name");
    $link .= "</a>";
    $category_list[$i++] = $link;

    }
    while (list(, $value) = each($category_list)) {
    $html .= $value;
    }

    return $html;
}
?>

and replace with:

function get_navigation_list($category_id, $pd = 0) {
    global $sess, $mosConfig_live_site;
    $db = new ps_DB;

    static $i=0;
    static $html = "";
    $q = "SELECT category_id, category_name,category_parent_id FROM #__{vm}_category, #__{vm}_category_xref WHERE ";
    $q .= "#__{vm}_category_xref.category_child_id='$category_id' ";
    $q .= "AND #__{vm}_category.category_id='$category_id'";
    $db->setQuery($q);   $db->query();
    $db->next_record();
    if (($db->f("category_parent_id")) && ($i == 0) && ($pd == 0)) {
    $link .= $db->f("category_name");
    $category_list[$i++] = " ".$this->pathway_separator()." ". $link;
    $this->get_navigation_list($db->f("category_parent_id"));
    }
    elseif ($db->f("category_parent_id")) {
    $link = "<a class=""pathway"" href="">url($_SERVER['PHP_SELF'] . "?page=shop.browse&category_id=$category_id");
    $link .= "">";
    $link .= $db->f("category_name");
    $link .= "</a>";
    $category_list[$i++] = " ".$this->pathway_separator()." ". $link;
    $this->get_navigation_list($db->f("category_parent_id"));
    }
    elseif (($i == 0) && ($pd == 0)) {
    $link .= $db->f("category_name");
    $category_list[$i++] = $link;
    }
    else {
    $link = "<a class=""pathway"" href="">url($_SERVER['PHP_SELF'] . "?page=shop.browse&category_id=$category_id");
    $link .= "">";
    $link .= $db->f("category_name");
    $link .= "</a>";
    $category_list[$i++] = $link;

    }
    while (list(, $value) = each($category_list)) {
    $html .= $value;
}

return $html;
}

After you replace the code, there are two more files that need to be edited. Search for the next file: /administrator/components/com_virtuemart/html/shop.product_details.php

Find the following line of code:

	$navigation_pathway .= $ps_product_category->get_navigation_list($category_id);
	$navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $product_name;

and replace with:

	$navigation_pathway .= $ps_product_category->get_navigation_list($category_id, 1);
	$navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $product_name;

After that we have one last file to edit…we’re almost done.

Open /includes/pathway.php

Find the following line of code:

    // if it is the current page, then display a non hyperlink
    if ($item->id == $Itemid || empty( $mid ) || empty($item->link)) {
    $newlink = "  $itemname";

and replace with:

    // if it is the current page, then display a non hyperlink
    if (($item->id == $Itemid && !$mainframe->getCustomPathWay()) || empty( $mid ) || empty($item->link)) {
    $newlink = "  $itemname";

Now you have edited 3 different files. Make sure you save and back up your files. Now upload these to the server over the original files and you will have working pathways for your shop.

Update:

Lastly, open all the templates located in /administrator/components/com_virtuemart/html/templates and delete the following code from all of your templates: {navigation_pathway}. This will conclude your pathway issues to make them just like ours.

Enjoy!

STAY UP TO DATE

Sign up today to stay informed with industry news & trends