Sunday, June 6, 2010

Broken links for product additional files in Virtuemart 1.1.4, Joomla 1.5.15 and SEF turned on

We still have to run our website in legacy mode because Virtuemart is still natively incompatible with Joomla 1.5.x.  The migration to Joomla 1.5.x is obviously incomplete as there is still minor bugs here and their.  One of the bugs which I was unable to find an answer to on the web is the shop.getfile bug.  In virtuemart, you can upload downloadable files against a product, and it will appear to be available for download.

After adding the additional files, there is a link which appears on the bottom of the product details page allowing the user the download the file you just added.

Unfortunately with our setup, the generated URL for the downloadable file was incorrect.  Debugging this issue was painful as I was unable to get XDebug to work properly.  The Apache child process on my local development environment just keep crashing when ever I have the debugger attached, but this is a long story possibly for another separate entry.  It turns out the components/com_virtuemart/router.php was missing the shop.getfile entry and I have to manually added it back it.  Inside the virtuemartBuildRoute function add the shop.getfile case into the switch statement.  It will look something like this:

case 'shop.getfile';
  $segments[] = 'products_getfile';
  $segments[] = $query['product_id'];
  $segments[] = $query['file_id'];

Then in the virtuemartParseRoute function, add the corresponding code to handing the routing statement created above.  It will look something like this:

case 'products_getfile':
  $vars['page'] = "shop.getfile";
    $vars['product_id'] = $segments[1];
    $vars['file_id'] = $segments[2];

Adding the above code back in and the additional file links for products works again!

I would like to submit a patch to Virtuemart.  Unfortunately, it appears the development issue tracker at is not open to public submissions. Hopefully this problem is eventually spotted and fixed by the Virtuemart development team.


  1. Thank you very much, just saved me loads of time! I'm not sure which version of Virtuemart you were using but it worked for v1.1.4

    Good work :)

  2. Thanks for the comment. I am quite new to the blogger scene and I am glad my posting is helping fellow developers like yourself.

  3. Hi, thank you for your tip which is correct and hopefully will be fixed soon.
    But there is one important thing to say: VM does NOT need "Legacy mode". I am sure: i have installed dozens of shops for me, my customers, and testing purposes.
    Are you sure you are not still using the VM package for Joomla 1.0?

  4. Thanx, Leonard! You sure saved me a great deal of time!