VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: stevewc84 on May 28, 2012, 11:04:19 AM

Title: VirtueMart URL ?Itemid=0
Post by: stevewc84 on May 28, 2012, 11:04:19 AM
I am new to VirtueMart and I have recently created a VirtueMart 2 site on Joomla 2.5 .

Using Joomla 2.5 standard SEO SEF settings - it seems to work perfectly apart from actual shop items where it adds ?Itemid=0 onto the end of each URL

I dont want this to appear at all - I want the URL to get to .html and that's it - I don't want any ?Itemid to show after the URL.

Can anyone give me some advice on how I can achieve this?

Many Thanks

Steven
Title: Re: VirtueMart URL ?Itemid=0
Post by: stevewc84 on May 29, 2012, 11:45:21 AM
Does anyone know how to fix this?
Title: Re: VirtueMart URL ?Itemid=0
Post by: stevewc84 on May 29, 2012, 12:19:01 PM
I am really not sure what I should be doing here - but maybe its something to do with the virtuemart component router.php file - can I edit anything here to stop the Itemid from displaying in the URL?
Title: Re: VirtueMart URL ?Itemid=0
Post by: PRO on May 31, 2012, 17:08:40 PM
stevewc84, do you have a menu link to the vmart frontpage?

and are you saying it adds the Itemid=0   when SEF turned on?

are you using 3rd party sef component?


Title: Re: VirtueMart URL ?Itemid=0
Post by: szbstvn on July 26, 2012, 08:02:41 AM
My problem is same

do you have a menu link to the vmart frontpage? ... YES

and are you saying it adds the Itemid=0   when SEF turned on? .... YES

are you using 3rd party sef component? .... NO
Title: Re: VirtueMart URL ?Itemid=0
Post by: cristirp on August 25, 2012, 20:40:39 PM
Did you find a solution to this?
Thank you  :D
Title: Re: VirtueMart URL ?Itemid=0
Post by: GooRu on August 26, 2012, 03:38:58 AM
I'm having the same issue.

In the config it has a place in the SEO options to enable translation strings which from what I can tell would take care of the add-on item id at the end of the URL and it is checked but is in effective...

What's up?
Title: Re: VirtueMart URL ?Itemid=0
Post by: cristirp on August 26, 2012, 15:12:51 PM
The interesting thing I've discovered for my website is that it only happens for some products. There's some that have perfect SEF... but others have the Itemid=0 at the end as well as the component/virtuemart part after the domain.
Title: Re: VirtueMart URL ?Itemid=0
Post by: ben1390 on September 04, 2012, 15:10:12 PM
I am also experiencing this issue but it appears to only be present on products that have custom fields associated with them
Title: Re: VirtueMart URL ?Itemid=0
Post by: ptogel on September 04, 2012, 21:20:25 PM
Same here. I'm using Joomla! 2.5.6 with VirtueMart 2.0.10 and the standard, build-in Joomla SEO. Any idea how to fix it?
Title: Re: VirtueMart URL ?Itemid=0
Post by: ben1390 on September 05, 2012, 11:30:52 AM
I appear to have found a solution to this, my VM category that my product sat in was not assigned to a menu item. Creating a menu item linked to the VM category in question seemed to have solved it.
Title: Re: VirtueMart URL ?Itemid=0
Post by: cristirp on September 13, 2012, 01:34:41 AM
I already had a menu item with VM in it. However, I changed the menu item to Category Layout and selected the Top Level Category, and that fixed it!!  :D Thanks for the tip
Title: Re: VirtueMart URL ?Itemid=0
Post by: DH on October 04, 2012, 19:21:28 PM
What is going on? It showes as exactly what you said, only those items that the categories not assigned to a menu item appeared such issue. However, I am using megamenu, no enough space for assigning all the categories to it.

Looking for another way out... ...
Title: Re: VirtueMart URL ?Itemid=0
Post by: alepoudaki on January 23, 2013, 14:46:32 PM
Any solution to that? My ItemId =0  is wrong too. How can I find the proper one???
Title: Re: VirtueMart URL ?Itemid=0
Post by: PRO on January 23, 2013, 15:41:10 PM
Quote from: DH on October 04, 2012, 19:21:28 PM
What is going on? It showes as exactly what you said, only those items that the categories not assigned to a menu item appeared such issue. However, I am using megamenu, no enough space for assigning all the categories to it.

Looking for another way out... ...

use a hidden menu

Title: Re: VirtueMart URL ?Itemid=0
Post by: Sirinidis Nikolaos on September 24, 2013, 16:55:08 PM
ok, this might be an old topic but problem still exists in VM 2.0.22c

here is my quick fix/solution:
you have to edit router.php file that is located in /components/com_virtuemart/
somewhere around line 764 you will find a function called "getCategoryRouteNocache"
now you have to replace variable "$category->itemId" (line 768) with the code below:

$menu   = JFactory::getApplication()->getMenu();
//get menu item with virtuemart link
$item = $menu->getItems('link', 'index.php?option=com_virtuemart&view=categories&virtuemart_category_id=0', false);
if ($item[0]->id < 0)
{
$item = $menu->getItems('link', 'index.php?option=com_virtuemart&view=virtuemart', false);
}
//set item id
$category->itemId = $item[0]->id;


this solutions also fixes the problem with SEF url for category module and all other modules that uses JRoute::_ function to generate links
Title: Re: VirtueMart URL ?Itemid=0
Post by: Milbo on September 26, 2013, 18:30:54 PM
the function looks now like this


/* Get Joomla menu item and the route for category */
public function getCategoryRouteNocache($virtuemart_category_id){
if (! array_key_exists ($virtuemart_category_id . $this->vmlang, self::$_catRoute)){
$category = new stdClass();
$category->route = '';
$category->itemId = 0;
$menuCatid = 0 ;
$ismenu = false ;

// control if category is joomla menu
if (isset($this->menu['virtuemart_category_id'])) {
if (isset( $this->menu['virtuemart_category_id'][$virtuemart_category_id])) {
$ismenu = true;
$category->itemId = $this->menu['virtuemart_category_id'][$virtuemart_category_id] ;
} else {
$CatParentIds = $this->getCategoryRecurse($virtuemart_category_id,0) ;
/* control if parent categories are joomla menu */
foreach ($CatParentIds as $CatParentId) {
// No ? then find the parent menu categorie !
if (isset( $this->menu['virtuemart_category_id'][$CatParentId]) ) {
$category->itemId = $this->menu['virtuemart_category_id'][$CatParentId] ;
$menuCatid = $CatParentId;
break;
}
}
}
}
if ($ismenu==false) {
if ( $this->use_id ) $category->route = $virtuemart_category_id.'/';
if (!isset ($this->CategoryName[$virtuemart_category_id])) {
$this->CategoryName[$virtuemart_category_id] = $this->getCategoryNames($virtuemart_category_id, $menuCatid );
}
$category->route .= $this->CategoryName[$virtuemart_category_id] ;
if ($menuCatid == 0  && $this->menu['virtuemart']) $category->itemId = $this->menu['virtuemart'] ;
}
self::$_catRoute[$virtuemart_category_id . $this->vmlang] = $category;
}

return self::$_catRoute[$virtuemart_category_id . $this->vmlang] ;
}


How do you mean it? Maybe the new functions fixes it, or you have a better method. Lets discuss it out :-)
Title: Re: VirtueMart URL ?Itemid=0
Post by: Sirinidis Nikolaos on September 28, 2013, 11:11:44 AM
sorry if I am not that clear :)

Now, in this function... you set
$category->itemId = 0;

and then you make some checks..
first check " if (isset($this->menu['virtuemart_category_id'])) " fails because we are not in any virtuemart category since we are in frontpage and virtuemart is not set as default homepage.
so we then go to the second check " if ($ismenu==false) ".... yes it's false because we have already set it before
then we have "  if ($menuCatid == 0  && $this->menu['virtuemart']) " that fails to assign $this->menu['virtuemart']  to $category->itemId
because $this->menu['virtuemart'] is not set...
and that is how we stuck with $category->itemId = 0; that we have earlier defined.

I don't now if I am correct..
but that is what I thought and understood when I checked your code.


so what I did was to use joomla's methods to get an item id from the first menu item that will have " index.php?option=com_virtuemart&view=categories&virtuemart_category_id=0 " or " index.php?option=com_virtuemart&view=virtuemart "
and then set $category->itemId instead of just having it as 0

download router file from here http://www.netikon.gr/joomla-extensions

Title: Re: VirtueMart URL ?Itemid=0
Post by: keran on September 28, 2013, 22:09:43 PM
Sirinidis Nikolaos Thank You! Your router.php fix works! Great job :)
Title: Re: VirtueMart URL ?Itemid=0
Post by: gas79 on May 25, 2015, 23:04:03 PM
Hi, after going crazy for some days, and didn't want to touch the router.php core files, I discovered that my only two products that showed 'ItemId=0' had the field 'URL', in the 'Information' tab valorized!
I cleared the 'URL' field, and 'ItemID=0' disappeared, showing my SEF url as expected.
I hope this could help someone.
Bye.