VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: buzi on November 01, 2012, 11:13:32 AM

Title: [ SOLVED ] redirect a category to product details page
Post by: buzi on November 01, 2012, 11:13:32 AM
Hi,
i'm quite sure if this is the right section, but here goes:

id'e like a specific category to go directly to a specific product details page
i don't think this can be done by configuration.
if you are asking why i dont create a menu item to point to the product details , well its complicated.

tried using the joomla generic redirect component, and other redirect components, even tried to change the .htaccess like this:

Redirect 301 /index.php?option=com_virtuemart&view=category&virtuemart_category_id=10 http://www.mysite.com/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=94&virtuemart_category_id=10

but none of those work (other .htaccess rules do work)
im guessing there is some in-code url generation that produces those links and overrides the .htaccess.

any ideas how to approach this ?

Thanks 
Title: Re: redirect a category to product details page
Post by: PRO on November 01, 2012, 14:18:06 PM
create a separate "category layout" template

Then. in the category, set it to the new layout

Then, you can use this code in it

<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();
   if (!$app->isAdmin()) {
$app->redirect('url-to-redirect-to', null, null, true, true);
}

Title: Re: redirect a category to product details page
Post by: buzi on November 04, 2012, 12:51:22 PM
very nice PRO, it worked like a charm.
Thank you very much. :)
May the force be with you.