Author Topic: virtuemart itemid problem  (Read 15565 times)

firdavs_abc

  • Beginner
  • *
  • Posts: 3
virtuemart itemid problem
« on: May 03, 2010, 21:29:43 pm »
site: www.best-gm.com
joomla version: 1.5.15
Virtuemart version: 1.1.4
i have created 2 main categories in virtuemart and many sub categories inside of them.
On my main page, i assigned the first category to Faucets menu and the second category to Sinks menu. when i click on the Sinks menu, the subcategory of the assigned category shows up. But those subcategories' itemids are the Faucets menu's itemid. when i unpublish the Faucets menu the itemid's of the Sinks became correct, and the moment i publish the Faucets menu the problem starts again.
how can i fix this virtuemart's bug?

thanx

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: virtuemart itemid problem
« Reply #1 on: May 04, 2010, 03:23:30 am »
Instead of 2 menu items pointing to VirtueMart (which, as you point out causes Joomla to assign 2 different Itemids to VirtueMart), put a VirtueMart module which lists the 2 categories on your main page.  To the user, it still looks like 2 menu items.  Since it's not a Joomla menu, but rather a VM module, it will only have 1 VM Itemid and your shop will operate correctly.

firdavs_abc

  • Beginner
  • *
  • Posts: 3
Re: virtuemart itemid problem
« Reply #2 on: May 04, 2010, 16:49:05 pm »
actually i want the virtuemart to assign different itemids to each menu. but the problem is that the virtuemart assigns wrong itemids to its subcategories.

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: virtuemart itemid problem
« Reply #3 on: May 04, 2010, 17:29:49 pm »
VirtueMart saves only one Itemid in its "session" information which I believe is the first Joomla Itemid it finds in the database assigned to VM.  If your site assigns more than one Joomla Itemid to VM, visitors to your site will encounter problems as you have described because their VM session data's Itemid may be different than the menu's Itemid.  If your site only uses one Joomla Itemid for VirtueMart you will not encounter these problems.

firdavs_abc

  • Beginner
  • *
  • Posts: 3
Re: virtuemart itemid problem
« Reply #4 on: May 05, 2010, 17:40:48 pm »
rb you are going to laugh, but i kind of found a solution.
i have changes some script in administrator\components\com_virtuemart\classes\ps_session.php file
on line 511 I changed $tmp_Itemid=''; to $tmp_Itemid='1';
and added comment script /*  at 512th line
closed the comment script */ at 548 line, just before
      } else {
         $Itemid = NULL;
      }
script.

for now my site is working ok with it. i dont know what will happen in the future.

Crewz

  • Beginner
  • *
  • Posts: 1
Re: virtuemart itemid problem
« Reply #5 on: March 16, 2011, 19:12:22 pm »
firdavs_abc answer only deactivated the menu.

don't comment out the code instead look further in the administrator\components\com_virtuemart\classes\ps_session.php file at the function getShopItemid() and change it to :

function getShopItemid() {
      
   // MODTAG: RICHARD G. MAYER MOD
   if ( empty( $_REQUEST['shopItemid'] )) {
      $_REQUEST['shopItemid'] = $_REQUEST['Itemid'];
   }

   /*
   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;
         }
      }
   } */

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

}

This modification will get the current Itemid (which is the menu id currently in use) and set it.

vasx

  • Beginner
  • *
  • Posts: 1
Re: virtuemart itemid problem
« Reply #6 on: May 07, 2012, 00:18:15 am »
tried and its work for my site 1.5.26 and 1.1.9. thank you

jck

  • Beginner
  • *
  • Posts: 2
Re: virtuemart itemid problem
« Reply #7 on: May 24, 2012, 06:36:53 am »
@ Crewz   [SOLVED]  [SOLVED]  [SOLVED]

Yessssss !    :D   :D   :D
Thank you so much  !......

I have spent almost 6 hours yesterday on this problem, and tried many different things without any success.
At last ! I hope this would be a smart (little) update for all the people that need to stay with Virtuemart 1.x, and Joomla 1.5.x

Like vasx, my own versions are the last available (for today) :
Joomla 1.5.26 and VirtueMart 1.1.9