Using Dynamic404 with VirtueMart
Dynamic404 works flawlessly together with the Joomla! core as well as popular extensions like ZOO and K2. With VirtueMart however, there are various difficulties when trying to fetch 404-errors and making them useful for your visitors. The architecture of VirtueMart is outdated, but it's still possible to make use of Dynamic404. This tutorial describes a core hack in the code of VirtueMart to modify the 404-behaviour of VirtueMart.
This tutorial applies to VirtueMart 1.0 and 1.1.
Causing VirtueMart to throw real 404s
When VirtueMart is unable to find a certain product, it redirects back to another page and displays a simple message (PHPSHOP_PRODUCT_NOT_FOUND). To convert this page into a real error-page (displayed using Dynamic404) or to allow Dynamic404 to redirect to a proper page, you will need to modify the core-scripts of VirtueMart.
Please note that we do not recommend making core-hacks, even it is described in this tutorial. Core-hacks make it more difficult to upgrade and every core-hack should therefor be described carefully in your system documentation. We can not be made responsible for any problems that occur when making these modifications, so we urge you to keep proper backups in place.
Modifying product-pages
For product-pages you need to modify the script administrator/components/com_virtuemart/html/shop.product_details.php. Around line 64 you will find the following code-segment:
if( !$db_product->next_record() ) {
$vmLogger->err( $VM_LANG->_('PHPSHOP_PRODUCT_NOT_FOUND',false) );
return;
}
Replace this with the following:
if( !$db_product->next_record() ) {
if(file_exists(JPATH_SITE.DS.'components'.DS.'com_dynamic404'.DS.'dynamic404.php')) {
require_once(JPATH_SITE.DS.'components'.DS.'com_dynamic404'.DS.'dynamic404.php');
} else {
$vmLogger->err( $VM_LANG->_('PHPSHOP_PRODUCT_NOT_FOUND',false) );
}
return;
}
This makes sure that when Dynamic404 is installed, Dynamic404 is also called upon when a product can not be found. Once Dynamic404 is removed from your Joomla! site, the code will still work.
Installing the Dynamic404 plugin for VirtueMart
To make sure Dynamic404 is also able to search the VirtueMart tables, download the free Dynamic404 plugin for VirtueMart from our download-section. Install it using the Joomla! Installation Manager and enable it using the Plugin Manager.
The Dynamic404 plugin is not a magic solution, because it is only able to find limited information in the VirtueMart URL - simply because VirtueMart URLs lack vital SEO information like a product alias. In general, Dynamic404 is able to redirect invalid product URLs automatically to their parent category. You may still find this very useful, and you can still make manual redirects using Dynamic404.
Created on Tuesday, 21 December 2010Modified on Wednesday, 01 December 2010
More tutorials in this section
- Example redirect with Dynamic404
- Dynamic404 redirection rules
- Patching error.php with Dynamic404
- Using Dynamic404 with VirtueMart
- Installing and configuring Dynamic404
- Configuration-options for Dynamic404
