VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: Matt_Ginn on May 13, 2015, 15:55:26 PM

Title: SEF URLs in product admin
Post by: Matt_Ginn on May 13, 2015, 15:55:26 PM
We have a site (Joomla 2.5.28, VM2.6.18) http://www.mardens-trading.co.uk where we have SEO/SEF turned on in both Joomla and Virtuemart. Thus the product urls are, for example - http://www.mardens-trading.co.uk/portwest-workwear/workwear-jackets/tx60-texo-sport-jacket-detail. This is all working fine, however we're trying to use a component in the backend that automatically posts the product to our facebook page when you save the product. We'd like it to pass the SEF url for the product but I can't seem to find a way to access that in the product admin. The only values I can get from the product object are 'unfriendly' urls! Is there a property of the product object that holds the friendly version or can I use the router.php to translate it??
Title: Re: SEF URLs in product admin
Post by: jjk on May 13, 2015, 21:23:30 PM
I'm not aware of any method to display the frontend SEF url in the backend. Perhaps the developer of the facebook component can add that feature into his extension. I think it is possible to build the SEF url from an sql query. Some sitemap generators use that approach.
Title: Re: SEF URLs in product admin
Post by: PRO on June 17, 2015, 17:16:12 PM


Do you use joomla menu for categories?

If so,

I made a function that can get your started working on this
It will return the sef path to the category, as well as any other link that's in the menu.


function menuPathLink($mlink){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('path');
$query->from($db->quoteName('#__menu'));
$query->where($db->quoteName('link')." = ".$db->quote($mlink) );
$db->setQuery($query);
$row = $db->loadResult();
if (!empty($row)){return $row;}
else return $mlink;
}

So then, you just throw a non-sef category link into it, and then it returns the path


For example  here is a standard non-sef category link
index.php?option=com_virtuemart&view=category&virtuemart_category_id=11&virtuemart_manufacturer_id=0&categorylayout=0&showcategory=1&showproducts=1&productsublayout=0

So to use it, you just

echo menuPathLink('index.php?option=com_virtuemart&view=category&virtuemart_category_id=11&virtuemart_manufacturer_id=0&categorylayout=0&showcategory=1&showproducts=1&productsublayout=0');

& ofcourse, you have to have the virtuemart_category_id   be dynamic

THEN: place the product alias, and the -suffix to the end.
Of course, you need to add the base link.




Title: Re: SEF URLs in product admin
Post by: jessica_watson on June 18, 2015, 11:34:50 AM
You can do by downloading router.php, for detailed steps, you can check- http://paulmason.name/item/search-engine-friendly-sef-urls-for-virtuemart.
Title: Re: SEF URLs in product admin
Post by: jjk on June 18, 2015, 14:44:00 PM
Note that the file linked by Jessica is for Joomla 1.5 and VirtueMart 1.x. It will not work on Joomla 2.5.x/3.x and VM 2.x or 3.x.