VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Questions VM 1.1 ( the only active board for the old version) => Topic started by: LEGOmanden on July 11, 2008, 11:34:21 am

Title: $Itemid problem with mainmenu
Post by: LEGOmanden on July 11, 2008, 11:34:21 am
Setup:
Joomla 1.0.15
Virtuemart 1.1.1

File with problem: joomlaroot/administrator/components/virtuemart/html/shop.product_details.php
Line 40:
$Itemid = $sess->getShopItemid();

This resets the Itemid for the rest of the joomla :-(.
I'm using the option joomla mainmenu to create component-link to products in virtuemart so I can control modules on each productpage.
When joomla starts loading modules it then has a wrong $Itemid and the modules is no longer in control :-(
Further more I'm using sh404SEF and it's getting the wrong $Itemid for products and messes it up :-(

What happens, when I start using virtuemart as a shop instead of a catalog?
What about othere pages such as shop.browse (the category page in virtuemart)?

I have done a temp-fix resetting the Itemid in the bottom of the shop.product_details.php to $Itemid = $_REQUEST['Itemid']

Does anyone know a complete fix to this isue? Or is it a bug to be handled in the next virtuemart version?
Title: Re: $Itemid problem with mainmenu
Post by: Soeren on July 21, 2008, 13:24:41 pm
Hi,
how is it if you put the code under the pre-last line in the file virtuemart.php:

Code: [Select]
$Itemid = vmrequest::getint('Itemid');
$vm_mainframe->close();
?>

Please try that and report back...
Title: Re: $Itemid problem with mainmenu
Post by: LEGOmanden on July 21, 2008, 16:43:06 pm
Hey Sören and Thanx for the idea :-)

It's going the right way but...
It is correct, than virtuemart when it is done has the Itemid set to the origninal but when it comes to shop.browse the problem is a little bit more complex :-(

I product listet in shop.browse has a link to the shop.product_details and this link is stil with the $Itemid from virtuemart, and not the $Itemid from the mainmenu.

Cind regards


Title: Re: $Itemid problem with mainmenu
Post by: razor7 on July 25, 2008, 00:00:31 am
The same happens to me...

Please check out this site, http://www.escuela55.com.ar/inkpaper/opcion1
If you click the "BIC" logo, then all the BIC products will show up, but as you can see, there are a lot of products, so there is pagination.

The pagination results, override the given Itemid! I get allways Itemid=169 ¿?

Applied the patch suggested by soeren but nothing happens!

Please help!
Title: Re: $Itemid problem with mainmenu
Post by: razor7 on July 25, 2008, 00:49:06 am
Created bugtracker issue http://dev.virtuemart.net/cb/issue/2274?navigation=true
Title: Re: $Itemid problem with mainmenu
Post by: razor7 on July 29, 2008, 19:49:15 pm
Hello...any chance to review or fix this issue...it is driving me crazy!

 

Thanks a lot!
Title: Re: $Itemid problem with mainmenu
Post by: LEGOmanden on July 29, 2008, 23:43:32 pm
Hello... and no :-(

Nothing new and interesting... It seems that Sören has got something to think about *he he*
I guess they have'nt thougth that much about their use of $Itemid i the shop :-(

I allso hope for a fix to this soon.. I have to productionsites running virtuemart where I have this problem ..
Title: Re: $Itemid problem with mainmenu
Post by: Tri on August 01, 2008, 09:44:06 am
Hello.

In administrator/components/com_virtuemart/classes/ps_session.php
At the beginning of the method getShopItemid() of the class ps_session
Try to add this :
if(!empty($_REQUEST['Itemid']))
         $_REQUEST['shopItemid'] = $_REQUEST['Itemid'];
Title: Re: $Itemid problem with mainmenu
Post by: razor7 on August 04, 2008, 18:59:05 pm
It Works!

The ItemID, keeps the same as assigned to the menu, so i can assign many modules to a given product category!

Thanks again.

PS: Posted the workaround in the bugtracker too.
Title: Re: $Itemid problem with mainmenu
Post by: empati on October 10, 2008, 09:23:59 am
Thanks you very much for the solution.
Title: Re: $Itemid problem with mainmenu
Post by: darkos on October 16, 2008, 11:20:53 am
info: Joomla 1.5.7 + VM 1.1.2
*I also resolve this:
in administrator/components/com_virtuemart/classes/ps_session.php

*find:

if( !defined( '_VM_IS_BACKEND' )) {
         $Itemid = "&Itemid=".$this->getShopItemid();

*after:

"&Itemid="

*write some number:

"&Itemid=22"

*Save and exit ;D
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on November 16, 2008, 13:08:09 pm
Hello.
In administrator/components/com_virtuemart/classes/ps_session.php
At the beginning of the method getShopItemid() of the class ps_session
Try to add this :
if(!empty($_REQUEST['Itemid']))
$_REQUEST['shopItemid'] = $_REQUEST['Itemid'];

It works ! That's cool but there is another problem with the "related products"

Ex : flypage = product 1 / cat 1 + related products = product 2 / cat 4 ...

The product 2 is linked but the itemid stay in cat 1 :(


The "itemid" problem is very important ! Hope to fix that in the next update of Virtuemart, please :) Thanks !

Config : Joomla 1.5.8 - Virtuemart 1.1.2
Title: Re: $Itemid problem with mainmenu
Post by: MiRcOv on December 12, 2008, 15:12:33 pm
Hi at all, i'm arriving late but i've another solution that i think is better (i'm also preparing a live demonstration of the bug).

The original function is

Code: [Select]
function getShopItemid() {
if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE
...

You had modified the behavior of the function by changing the if ( if( !empty... ). It is not correct for me. The function is designed to work as is now.

The edit that can be made is another:

Try to edit the function in this way

Code: [Select]
function getShopItemid() {

if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $db->f("id");
}
else {
if( !empty( $_REQUEST['Itemid'] )) {
$_REQUEST['shopItemid'] = intval( $_REQUEST['Itemid'] );
}
else {
$_REQUEST['shopItemid'] = 1;
}
}

// HERE STARTS THE HACK
} else {
return intval($_REQUEST['Itemid']);
}
// HERE ENDS THE HACK
return intval($_REQUEST['shopItemid']);

}

The function is the same but if an Itemid is set the function does not changes it. And this is what we want ;):)
Title: Re: $Itemid problem with mainmenu
Post by: Lylene on December 18, 2008, 16:33:40 pm
Thanks for this info, I have been looking for a solution for weeks, with this Item Id problem. Now Item id mentionned is that of the menu. However, I need to have the breadcrumb to be displayed on each product page, and it seems it is not working with that modification.

I confirm : breacrumb module is properly set up + breadcrumbs were displayed before the change (BUT with the wrong ItemId).

Thanks for your help much appreciated !

Title: Re: $Itemid problem with mainmenu
Post by: Lylene on December 18, 2008, 17:04:34 pm
Sorry me again : apparently, the breadcrumb works ok if we are using it from standard browse page. However, all my products are also introduced via VM Latest Products module and breadcrumbs are not displayed on product page when coming from that module.

I finally found the problem on this issue, the breadcrumbs are dispayed only if the source page is authorising them : on homepage, there was no breadcrumbs displayed, clicking on a product from there makes it imposible to display breadcrumbs on the related product page. The solution was to display breadcrumbs on the homepage.
Title: Re: $Itemid problem with mainmenu
Post by: Lylene on December 18, 2008, 22:07:40 pm
Sorry to bother but another question comes out following the amendment I made (MiRcOv post). I have breadcrumbs for items that are not part of the menu. However, for these, breadcrumbs are not working. See example below:
Breadcrumbs are displayed for:
- Menu01
- Menu02
- Module (TopTen)
Let's say I have one item common to all the Menu/Modules listed above ITEM01 (CAT01/MENU01) (which is obvious)

If I am on homepage, breadcrumbs of the product page will be Home / MENU01/CAT01/ITEM01 =>OK

If I am on Menu01, breadcrumbs of the product page will be Home / MENU01/CAT01/ITEM01 =>OK

If I am on Menu02, breadcrumbs of the product page will be Home/MENU02/CAT01/ITEM01 => WRONG

Does anyone know how to correct this ?

Also, I have the same problem with VM Cart Module : Instead of displaying Home / My Cart, the breadcrumbs display Home / Menu01 / My Cart if I was on Menu01 already.

Thansk for your help,
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on December 21, 2008, 18:57:51 pm
The itemid problem make me crazy !
I've got new problems in my sitemap (sef_servicemap 2.0.10), in the related products, in the latest products ...
cause problems in indexation of my website in Google ... etc ... etc ...
??? PLEASE, can we have more informations ? or a REAL correction of this bug ?
Hope to fix this bug in the next (soon?) version of Virtuemart !
Many thanks !
Regards.
:-\ :'(
Title: Re: $Itemid problem with mainmenu
Post by: pagehosting4u on January 10, 2009, 19:59:17 pm
Setup:
Joomla 1.5.8
VirtueMart 1.1.2

I was able to use the info here to fix the itemid issue with the mainmenu, but the problem is throughout all modules. If I click on an item in the scrolling module, all products get itemid=xx added to the end of the urls. Where xx is the first product I added. If I click on a category, all products have itemid=xx added to the end of the urls. It amazes me that this post started over 6 months ago and this is still a problem. Please fix it.
Title: Re: $Itemid problem with mainmenu
Post by: Micha on January 10, 2009, 22:19:36 pm
Hi Joomlers,

I have also the same problem and i tried to implement the hack also but i see a error on mij front-end. I do not know exact what it was so i post that again. I use Joom 1.5.8 and VM 1.1.2

Hope a real solution get soon.

Micha

Update: modified the file for second time and it works! Menu is now expand good. ::)
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on January 11, 2009, 01:57:32 am
Hi

You can see in the Virtuemart news :
"Also an important maintenance release - VirtueMart 1.1.3 - is currently being prepared for release (next week), so stay tuned."

I hope a great fix for this bad bug !!!
Title: Re: $Itemid problem with mainmenu
Post by: Soeren on January 11, 2009, 13:25:17 pm
Hi,
I don't think this is a bug. It won't be "fixed" in VM 1.1.3. Itemid handling in Joomla! sucks, sorry.

ciao, sören
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on January 11, 2009, 13:47:44 pm
Hi,
I don't think this is a bug. It won't be "fixed" in VM 1.1.3. Itemid handling in Joomla! sucks, sorry.
ciao, sören

Really ? I'm confused. I believed that this bug was in virtuemart...
We have to declare this bug to the joomla squad  ...

Sorry Sören.
Title: Re: $Itemid problem with mainmenu
Post by: ILJ on January 11, 2009, 14:41:51 pm
Hi there

i went crazy with this problem now got some hints.
thank god.
is this virtuemart bug or joomla?
if Joomla we can forget abt it. cause 1.0 is over the support phase.

pls vm developers help us till we find an alternative.

thanks
ILJ
Title: Re: $Itemid problem with mainmenu
Post by: pagehosting4u on January 12, 2009, 22:25:28 pm
Hi,
I don't think this is a bug. It won't be "fixed" in VM 1.1.3. Itemid handling in Joomla! sucks, sorry.
ciao, sören
I am sorry to hear this. The problem seems to me to be VirtueMart not properly handling the Itemid. The VirtueMart menu item does not work in the main menu. ie, it doesn't matter what I put in for Flypage or Page, they don't get placed in the url that is created for the menu item. I had to go in and manually create all my menu items as external links.

Now that my main menu is working, the product scroll is not working. If I am browsing a product that has Itemid=57, then all products in product scroll module has Itemid=57 added to their urls. Therefore, when you click on a product, the product's details are shown, but there is a chance the wrong menu category is highlighted in the main menu. You can view the site I am working on here, http://74.53.203.210/~canary/

Another issue is with the VM extended search. If you follow this link, http://74.53.203.210/~canary/index.php?searchword=Sondra+Lewis&ordering=&searchphrase=all&option=com_search , you will see that all VM products listed in the search have "Candida and food allergy" as its product's category, when that is not true for the first item "Simple Choices..." What I do see is the WRONG category for the product followed by the correct category for the product. The urls also have Itemid=57 added to all of them. BTW, Itemid=57 just happens to be the very first item/category that I created in VM once I installed it.

Please take another look as it seems to me that all that is missing is the correct conditional checking for Itemid.
Thanks for a wonderful component.
Rick

PS. Once again, here is my setup:
Joomla 1.5.8
VirtueMart 1.1.2
Title: Re: $Itemid problem with mainmenu
Post by: Soeren on January 13, 2009, 07:06:17 am
Quote
BTW, Itemid=57 just happens to be the very first item/category that I created in VM once I installed it.

Try to delete that item from the main menu and try again.

ciao, Sören
Title: Re: $Itemid problem with mainmenu
Post by: pagehosting4u on January 13, 2009, 16:05:47 pm
I deleted the menu item Candida and Food Allergy and tried again. For the parameters I placed 7 in for the category ID and shop.browse for the page. It now appears that it is ignoring the parameters. If you go here, http://74.53.203.210/~canary/ and click on the menu item for Candida and Food Allergy, it does not take me to that page. It takes me to the default home page for VirtueMart as if I had just gone to http://74.53.203.210/~canary/index.php?option=com_virtuemart.
Anymore suggestions?

How do I remove the ItemID parameter off of the url links in the scrolling products window? I tried looking in the plugins folder and removing ItemID from the vmxsearch.plugin.php file, but no such luck.

Thanks for your help.
Rick
Title: Re: $Itemid problem with mainmenu
Post by: pagehosting4u on January 13, 2009, 16:44:17 pm
OK, this fix actually breaks the MainMenu and the VM Extended Search Plugin, I can't remember where I found it, but it has to with modifying components\com_virtuemart\virtuemart_parser.php
Code: [Select]
// Get the menu parameters, if any
if( vmIsJoomla( '1.5' ) ) {
$menu =& JMenu::getInstance('site');       // Added
$menuparams =& $menu->getParams($Itemid);  // Added
//$menuparams = $mainframe->getParams();
It now looks like MainMenu is now at least recognizing the category parameter, but seems to ignore the Flypage and Page parameters.

And the scrolling products still attached the Itemid of the current page that is showing. It would be nice if I could just remove the Itemid. I would rather have no menu item highlighted when selecting a product from the scrolling product module than have the wrong menu item highlighted.
Thanks for any help someone could give me.
Rick
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on January 17, 2009, 13:38:52 pm
Hi all,

Here you can see there is a hack for the itemid problem :

http://www.vm-expert.com/index.php?option=com_content&view=article&id=62:use-joomla-menu-for-virtuemart&catid=36:virtuemartexpertblog&Itemid=72

59€ !!!   ??? >:(  :'(
Title: Re: $Itemid problem with mainmenu
Post by: jingtian on January 19, 2009, 08:22:43 am
info: Joomla 1.5.7 + VM 1.1.2
*I also resolve this:
in administrator/components/com_virtuemart/classes/ps_session.php
*find:
if( !defined( '_VM_IS_BACKEND' )) {
$Itemid = "&Itemid=".$this->getShopItemid();
*after:
"&Itemid="
*write some number:
"&Itemid=22"
*Save and exit ;D

if u checkout, you will find the itemid for "continue shopping" is different . u will then not be able to load the correct itemid.
Title: Re: $Itemid problem with mainmenu
Post by: FatalMusic on January 22, 2009, 14:55:55 pm
The hack of vm-expert works. I figured out where to put it and tested it and it works :)


Open:

1. administrator/components/com_virtuemart/classes/ps_session.php

2. go to +/- line 497 where it says: $Itemid = "&Itemid=".$this->getShopItemid();

3. REPLACE THIS LINE with their code:

// Original Virtuemart Code:
// $Itemid = "&Itemid=".$this->getShopItemid();
// VM-Expert Hack – Start
if(!strpos($text, "category_id="===false)) {
parse_str(str_replace("amp;","",$text),$tk_arr);
if($tk_catid=intval($tk_arr['category_id'])) {
$db = new ps_DB;
$db->query("SELECT id from #__menu where link like '%option=com_virtuemart%' and params like '%category_id=$tk_catid%' and published=1");
if( $db->next_record() ) $result = $db->f("id");
/*
The same with Joomla-DB-Class: $db =& JFactory::getDBO();
$db->setQuery("SELECT id from #__menu where link like '%option=com_virtuemart%' and params like '%category_id=$tk_catid%' and published=1");
$result=$db->loadResult();
*/
if ($result) $tk_itemid=$result;
}
}
$Itemid = "&Itemid=" . ($tk_itemid ? $tk_itemid : $this->getShopItemid());
// VM-Expert Hack - End



et voila! :)
Title: Re: $Itemid problem with mainmenu
Post by: loiseau on January 24, 2009, 16:21:28 pm
After update to vm 1.1.3, always got the itemid problem :

I've tried the vm-expert hack and it's ok. That's cool ! But i've got a problem with some modules like the featured products : when I clik on a featured product, the link is not good (display the good product like shop.browse ?!)
I think I have to add a modification in the productsnapshot ...

But the vm-expert hack is ok, try this !

Thanks all
Title: Re: $Itemid problem with mainmenu
Post by: Micha on January 26, 2009, 11:20:43 am
With the hack my itemid problem is also solved but my breadcrumb is showing dubble items like: Mainpage/cat1/subcat1/cat1/subcat1
I turned it off until there is a good total solution. Thanks 4 the hack because that part is ok!

MiC
Title: Re: $Itemid problem with mainmenu
Post by: ctene on March 23, 2009, 17:12:22 pm
Fixed the problem in a different way - the problem file is the right one - in administrator/components/com_virtuemart/classes/ps_session.php change:

function getShopItemid() {

if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $db->f("id");
}

to

function getShopItemid() {

if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $_GET['Itemid'];
}

My best Guess and strongest suspicion is that this query:

$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");

produces the wrong result, I did not have much time to trace it all back to the reason but bypassed the issue with obtaining the correct item ID via a GET and nicely enough it even seems to work flawlessly with SEO URLz as well :) (but thats what we wanted to begin with, rite? :D)
Title: Re: $Itemid problem with mainmenu
Post by: webbie on June 10, 2009, 13:38:48 pm
Hi ctene!

thank you so much with that perfect solution! Works like a charm! You rock!
;)
Title: Re: $Itemid problem with mainmenu
Post by: ejohnson on June 18, 2009, 19:36:55 pm
Has anyone solved the problem with the $Itemid in Virtuemarts Extended Search Plugin? The URLs and Categories are all showing the same.

I've applied the VM-Expert Hack to the ps_session.php file and it's fixed issues like the pagination, but not this plugins. I've also edited the getShopItemid() to be:

Code: [Select]
if( empty( $_REQUEST['shopItemid'] )) {
   $db = new ps_DB;
   $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
   if( $db->next_record() ) {
      $_REQUEST['shopItemid'] = $_GET['Itemid'];
   }
   else {
      if( !empty( $_REQUEST['Itemid'] )) {
         $_REQUEST['shopItemid'] = intval( $_REQUEST['Itemid'] );
      }
      else {
         $_REQUEST['shopItemid'] = 1;
      }
   }
} else {
   return intval($_REQUEST['Itemid']);
}

return intval($_REQUEST['shopItemid']);

Am I missing something?

I deleted the menu item Candida and Food Allergy and tried again. For the parameters I placed 7 in for the category ID and shop.browse for the page. It now appears that it is ignoring the parameters. If you go here, http://74.53.203.210/~canary/ and click on the menu item for Candida and Food Allergy, it does not take me to that page. It takes me to the default home page for VirtueMart as if I had just gone to http://74.53.203.210/~canary/index.php?option=com_virtuemart.
Anymore suggestions?

How do I remove the ItemID parameter off of the url links in the scrolling products window? I tried looking in the plugins folder and removing ItemID from the vmxsearch.plugin.php file, but no such luck.

Thanks for your help.
Rick
Title: Re: $Itemid problem with mainmenu
Post by: marco on January 21, 2010, 23:36:32 pm
The problem in in the query: the query is:

find this: function url($text, $createAbsoluteURI=false, $encodeAmpersands=true, $ignoreSEF=false )

then you see the query (example for the category_id)

$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id%' AND published=1");

The problem is THIS: if i have in jos_menu an item with "category_id=33" and another with "category_id=3", the first one will always turns up even when i am linking to the "3" category. Is that clear?

I right query is:

$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id\n%' AND published=1");

---

note: you have to change % in \n% also in product_id search, flypage and page search.

THE ENTIRE RIGHT FUNCION IS HERE: change from

if(!defined('_VM_IS_BACKEND')) {

to

$Itemid = NULL;
}"

with this:



if(!defined('_VM_IS_BACKEND')) {
         
         // Strip the parameters from the $text variable and parse to a temporary array
         $tmp_text=str_replace('amp;','',substr($text,strpos($text,'?')));
         if(substr($tmp_text,0,1)=='?') $tmp_text=substr($tmp_text,1);
         
         parse_str($tmp_text,$ii_arr);

         // Init the temp. Itemid
         $tmp_Itemid='';

         $db = new ps_DB;
         
         // Check if there is a menuitem for a product_id (highest priority)
         if (!empty($ii_arr['product_id'])) {
            if ($ii_product_id=intval($ii_arr['product_id'])) {
               $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%product_id=$ii_product_id\n%' AND published=1");
               if( $db->next_record() ) $tmp_Itemid = $db->f("id");
            }
         } else {
            // Check if there is a menuitem for a category_id
            // This only checks for the exact category ID, it might be good to check for parents also. But at the moment, this would produce a lot of queries
            if (!empty($ii_arr['category_id'])) {
               $ii_cat_id=intval($ii_arr['category_id']);
               if ( $ii_cat_id && $tmp_Itemid=='') {
                  $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id\n%' AND published=1");
                  if( $db->next_record() ) $tmp_Itemid = $db->f("id");
               }
            }
            // Check if there is a menuitem for a flypage
            if (!empty($ii_arr['flypage'])) {
               $ii_flypage=$db->getEscaped(vmget($ii_arr,'flypage'));
               if ($ii_flypage && $tmp_Itemid=='') {
                  $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%flypage=$ii_flypage\n%' AND published=1");
                  if( $db->next_record() ) $tmp_Itemid = $db->f("id");
               }
            }
            // Check if there is a menuitem for a page
            if (!empty($ii_arr['page'])) {
               $ii_page=$db->getEscaped(vmget($ii_arr,'page' ));
               if ($ii_page && $tmp_Itemid=='') {
                  $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%page=$ii_page\n%' AND published=1");
                  if( $db->next_record() ) $tmp_Itemid = $db->f("id");
               }
            }            
         }
         // If we haven't found an Itemid, use the standard VM-Itemid
         $Itemid = "&Itemid=" . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());
      } else {
         $Itemid = NULL;
      }



it works!



Title: Re: $Itemid problem with mainmenu
Post by: palden on January 28, 2010, 09:37:43 am
thanks ctene ! you code works for me as well !! Cheers !!!
Title: Re: $Itemid problem with mainmenu
Post by: palden on January 28, 2010, 09:53:05 am
Oops! hang-on ! the solution from ctene works on this problem at this side, but messed up the check out page in the other side. you will seen the check out page contains the category page.  Not perfect yet.

hope a perfect solution comes out soon !

Title: Re: $Itemid problem with mainmenu
Post by: noojeeit on November 16, 2010, 07:26:05 am
So, Virtuemart 1.1.5 menu routing mostly works, but I want the default ItemId to be the link to the store front, rather than just whatever the first random menu link to a store item happens to be.  The following patch achieves this, and my routing now works as expected:

Code: [Select]
diff --git a/administrator/components/com_virtuemart/classes/ps_session.php b/administrator/components/com_virtuemart/classes/ps_session.php
index 8f6ac15..b4a7293 100644
--- a/administrator/components/com_virtuemart/classes/ps_session.php
+++ b/administrator/components/com_virtuemart/classes/ps_session.php
@@ -460,11 +460,19 @@ class vm_ps_session {
 
                if( empty( $_REQUEST['shopItemid'] )) {
                        $db = new ps_DB;
-                       $db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
-                       if( $db->next_record() ) {
+                       $db->query( "SELECT id,params FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
+                       while( $db->next_record() ) {
+                               $params = $db->f("params");
+                               foreach(array("product_id", "category_id", "flypage", "page") as $parameter) {
+                                       if (strpos($params,$parameter."=\n")!==false) {
+                                               continue 2;
+                                       }
+                               }
                                $_REQUEST['shopItemid'] = $db->f("id");
+                               break;
                        }
-                       else {
+               }
+               if( empty( $_REQUEST['shopItemid'] )) {
                                if( !empty( $_REQUEST['Itemid'] )) {
                                        $_REQUEST['shopItemid'] = intval( $_REQUEST['Itemid'] );
                                }
@@ -472,7 +480,6 @@ class vm_ps_session {
                                        $_REQUEST['shopItemid'] = 1;
                                }
                        }
-               }
 
                return intval($_REQUEST['shopItemid']);
Title: Re: $Itemid problem with mainmenu
Post by: yiun on July 03, 2011, 02:15:44 am
If someone has the problem again:

First create a UserClass directory:
Quote
./components/com_virtuemart/themes/default/user_class/

Then create a file:
Quote
./components/com_virtuemart/themes/default/user_class/ps_session.php

Here overwrite the method getShopItemid(). For example:
Quote
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

class ps_session extends vm_ps_session {

   function getShopItemid() {

      if( empty($_REQUEST['shopItemid']) ) {

         if( $_REQUEST['page'] == "shop.product_details"
            || $_REQUEST['page'] == "shop.browse"
         ){
            
            $_REQUEST['shopItemid'] = 3;
         }

         else if( $_REQUEST['page'] == "account.billing"
            || $_REQUEST['page'] == "account.index"
         ){

            $_REQUEST['shopItemid'] = 4;
         }
            
         else{
            $_REQUEST['shopItemid'] = 5;
         }

      }

      return intval($_REQUEST['shopItemid']);

/*      it is also possible to use the parent method:*/
/*      return parent::getShopItemid();*/
   }

}

If the class is called by virtuemart our function will used instead of the normal function.
To this example: If the variable $shopItemid isnt set, so our method will do it: If the page is "shop.product_details" or "shop.browse" with 3; if it is "account.billing" or "account.index" with 4; otherwise with 5. Then the value will returned.

Now you just have to modify the pages/itemsIDs for your project.
Title: Re: $Itemid problem with mainmenu
Post by: Kub on July 10, 2011, 18:46:01 pm
Hello,

i need help for this Script, i will use per Category other ItemId´s, but the Script works not correctly?

Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
class 
ps_session extends vm_ps_session {
function getShopItemid() {
if( empty( $_REQUEST['shopItemid'] )) {

$category_id vmGet($_REQUEST'category_id'0);


$db = new ps_DB;
$q "SELECT * FROM #__{vm}_category,#__{vm}_category_xref ";
$q .= "WHERE #__{vm}_category.category_id='$category_id' ";
$q .= "AND #__{vm}_category_xref.category_child_id=#__{vm}_category.category_id";
$db->query($q);
$db->next_record();
echo $db->f('category_parent_id');
$catid $db->f('category_parent_id');

if ($catid == "1") {
$_REQUEST['shopItemid'] = 9;

else if ($catid == "2") {
$_REQUEST['shopItemid'] = 10;
}
else if ($catid == "3") {
$_REQUEST['shopItemid'] = 11;
}
else if ($catid == "4") {
$_REQUEST['shopItemid'] = 12;
}
else if ($catid == "5") {
$_REQUEST['shopItemid'] = 13;
}
else if ($catid == "6") {
$_REQUEST['shopItemid'] = 14;
}
else {
$_REQUEST['shopItemid'] = 15;
}

return intval($_REQUEST['shopItemid']);
}

}

?>

Thanks
Title: Re: $Itemid problem with mainmenu
Post by: yiun on July 16, 2011, 05:43:27 am
Hi Kub,

on the first view I can't see any mistake. Maybe there is s.th. wrong in the database-query.
Check the value of $catid! Is it ok?

You have to specify the problem, "works not correctly" isn't enough.
Have you recognized any changes since you have implemented the script?

Don't forget the correct filename/directory and (especially in Linux) the file-privileges!

Hope you haven't give up yet  :P
Title: Re: $Itemid problem with mainmenu
Post by: Kub on July 16, 2011, 11:32:39 am
Hi yiun,

i think the Problem is
Code: [Select]
$category_id = vmGet($_REQUEST, 'category_id', 0); i must make a Db Select without this, but i havent a Idea. Can you help?
Title: Re: $Itemid problem with mainmenu
Post by: yiun on July 17, 2011, 19:18:17 pm
With the command you are just searching in the request-variable (which is defined by POST-Method) for the "category_id". The following command searches in the request-variable (POST-method) AND in the url (GET-method).
Code: [Select]
$category_id = vmRequest::getInt('category_id');It is also possible to set a default-value and just allow one method (GET or POST).
In this file you'll find all the methods with possible parameters:
Code: [Select]
./administrator/components/com_virtuemart/classes/request.class.php
I assume you know the GET- and POST-method. If not, just google "html get post".

Hope it helps!