Monday, February 10, 2014

Virtuemart 2 - How to remove SEO Suffix from Product Details aka -detail

If your using Virtuemart 2+ it requires you to use a -detail or .html  as a suffix for product pages.  Which really sucks if you are use to using SH404sef or some other plugin that will correctly re-route your URLs and make them nice. SH404sef no longer works with Virtuemart thus we are stuck with the default router. Here is how I fixed the router.php (included at the bottom for your downloading pleasuere)


Since there is not a plugin I dove into the router.php and made some simple quick fixes to ignore the SEO_Suffix and load products.

Around line 633
Code looked for categories in the last segment

$vars['virtuemart_category_id'] = $helper->getCategoryId (end($segments) ,$helper->activeMenu->virtuemart_category_id);
    $vars['view'] = 'category' ;

Changed to
$product = $helper->getProductId($segments ,$helper->activeMenu->virtuemart_category_id);
    $vars['virtuemart_product_id'] = $product['virtuemart_product_id'];
   $vars['virtuemart_category_id'] = $product['virtuemart_category_id'];


//codepyro - removed suffix from router 
  //check if the last segment is a product. 
  //if so then load the product details page instead of category 
 if(isset($vars['virtuemart_product_id']))
  {
   $vars['view'] = 'productdetails';
  }
  else
  { 
   $vars['virtuemart_category_id'] = $helper->getCategoryId (end($segments) ,$helper->activeMenu->virtuemart_category_id);
   $vars['view'] = 'category' ;
  }

Around line 943
//codepyro hack to remove suffix  
  if($this->seo_sufix_size >0)
   $productName =  substr($productName, 0, -(int)$this->seo_sufix_size );



You can download the updated router.php for Virtuemart 2.0.26d  

upload and replace the file
/components/com_virtuemart/router.php

updated 3.14.14 - I didn't realize that the site I had made these adjustments to all of the categories were set as menu items which of course makes a big difference. Anyway the zip file has been updated with the latest router.


Stumble Upon CodePyro

23 comments:

Anonymous said...

Hu,
Thank u for very helpful post!:) Can u help me a bit?
I need a suffix word, but I would like this order:
#suffix word - product title

I would be very grateful if you could help, thank you!

Josh Tischer :: CodePyro said...

Can you explain further what you are looking for? Is it something like
/category/SUFFIX-product

Josh Tischer :: CodePyro said...

Just got another comment and it appears to have been deleted. If you need help fixing this on your site, let me know.

Олег Луценко said...

Hi, Josh

Thanks for your fix, but it's doesn't work for Joomla 2.5.19 VM 2.0.26

I'll be very glad for your help



Josh Tischer :: CodePyro said...

send me your router file i would be happy to take a look. info at codepyro.com

Anonymous said...

Thenk you form Russia.

Олег Луценко said...

Hi, Josh
Thank you for help!!!
Your router.php is what I was looking for.
Best regards

Anonymous said...

hi, for J 2.5.20. no work :-( sorry can you upgrade it? thanks

Anonymous said...

this solution does not work on Virtuemart 2.6

jorg gray said...

Any company claiming to be an affordable Dallas Affordable SEO Services solution included, really should be adding value to your company

Mary Hickman said...

very unique blog

Affordable Search Engine Optimization

Anonymous said...

Hi Josh
Thank you for this hint...
But I'm now migrating to Virtuemart 3.x, and this hack seems not working anymore: do you have some suggestions to get it working again on new 3.x VM series? Thank you in advance for any help.
Regards

jorg gray said...

We provide white-hat SEO services that deliver long-term results to companies in the Dallas/Fort Worth area. Contact us now for a FREE SEO site audit affordable SEO Dallas.

faizan qureshi said...

You could have increased the very important concern.. thank you intended for revealing.. my spouse and i should browse much more provide problems with this weblog.. maintain putting up.. Web optimization Baclinks  Blog Commenting Service And Seo Services.

Muneer Ahmed said...

Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! dallas seo

Deborah Richards said...

Wonderful!! this is really one of the most beneficial blogs I’ve ever browsed on this subject. I am very glad to read such a great blog and thank you for sharing this good info with us. http://www.john-pierres.com/seo/why-is-search-engine-optimization-so-huge-for-your-business-success/

Seo said...

Hello there, My spouse and i discover scanning this article a new enjoyment. It is quite very helpful and useful and extremely considerably looking forward to examining more of your do the job. All In One Seo Backlinks To Rank You In 5$

Richard C. Lambert said...

Which really sucks if you are use to using SH404sef or some other plugin that will correctly re-route your URLs and make them nice seo

Adiba Alam said...

Real part of the total populace is getting to web for host of purposes. Be that as it may, of these reason, the need to accumulate more data holds the need. whakki-media.co.uk

mind.it said...

I love this blog!! The flash up the top is awesome!! www.rankible.com

mayazoe said...

How do you promote your business with backlinks? There are of course several ways to promote your business and promoting it with backlinks is one of the very best.
link building services

devidmiller5060 said...

Technical writing blog is a virtual content on any technical concept, including, engineering, aeronautics, marine, geographical surveys, oil explorations, advertising, media, sound or for that matter anything which has a scientific relation.
fashion school

jowdjbrown said...

I couldn't have asked for a simpler read with great tips like this... Thanks! What do Internet Marketing services include

Post a Comment