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.