Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

[Solved] Virtuemart: Show related products by category on flypage

[Solved] Virtuemart: Show related products by category on flypage

Hi,

If you need, like I did, to create an "Other products you might be interested in" module for virtuemart where the module shows more products from the same category of the product the user is viewing, here's the solution courtesy of metamod guy (brilliant):

(Note: this solution uses the "Virtuemart Products" module)

To set up, get the "target" module prepared with everything the way you want it to appear.

The settings I used in the Virtuemart Products module are:

  • Layout: default
  • Display: random products
  • Display Style: div based
  • Use Category Filter: Yes



The critical thing is "use category filter: yes". It does not matter which category this is set to initially, as MetaMod will manipulate the category.

In the MetaMod I used this:

$vm = JomGenius("virtuemart");
$cat = $vm->info("category_id");
if ($cat) {
  $changes->mod(109)->setParam("virtuemart_category_id",$cat);
  return 109;
}

In my case, I didn't restrict this to only product detail pages. To restrict it to product detail pages you can do this:

$vm = JomGenius("virtuemart");
$cat = $vm->info("category_id");
if ($cat and $vm->check("pagetype startswith productdetails") ) {
  $changes->mod(109)->setParam("virtuemart_category_id",$cat);
  return 109;
}


Another option would be to change the title of the module, to reflect the category name:

$vm = JomGenius("virtuemart");
$cat = $vm->info("category_id");
if ($cat and $vm->check("pagetype startswith productdetails") ) {
  $changes->mod(109)
  ->setParam("virtuemart_category_id",$cat)
  ->title("Products: " . $vm->info("category_name"))
  ->showTitle(true);
  return 109;
}

Note: you need to put in the module id of the target module in 2 places. My example used module 109 as my target module.

THANKS METAMOD GUY! big_smile

ironlion37
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1674
Total Polls:
6
Total Posts:
5919
Dormant:
User Info:
 
Total Users:
11785
Newest User:
sprinklerrepairmax
Members Online:
1
Guests Online:
91

Online: 
sprinklerrepairmax

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked