VirtueMart 1.1.x [ Old version - no longer supported ] > Frontend Modules VM 1.1

Hack to use randomprod module for multiple categories

(1/2) > >>

This tip is inspired from this post:

I decided to repost it because with a little mod (suggested in the topic as well), it works on VM 1.1.2,
i tried it as well, and it works in vm 1.1.5

if you want randomprod to fetch its items from many categories at once
(in my case)if a parent category does not have products directly,
but its children categories have products,
and we want to show these in the random prod, (i filled them manually one by one using this hack,by the way. but it would be still better than nothing!)

go to this file:

line 33,
and remove the "(int)" (without blockquotes)from the following:

--- Quote ---
--- Code: ---$category_id = (int)$params->get( 'category_id', 0 );
--- End code ---

it should be on line 33.
--- End quote ---

--- Quote ---find the line:

--- Code: ---$q .= "AND #__{vm}_category.category_id='$category_id'";

--- End code ---
and replace with

--- Code: ---$category_id_mod = "'".str_replace(",","','", $category_id)."'";
$q .= "AND #__{vm}_category.category_id IN ($category_id_mod)";
--- End code ---

In the Random Product Module, be sure to separate your category IDs with commas for example:


--- End quote ---

so here's what this hack does:
instead of considering the "category id" as 1 number,
it retrieves it as a text,
and picks the categories from the text (provided you have already separated them with commas)
and makes the module choose the randproduct -->IN<-- those numbers

many thanks to canreo and zdjl505 for the hack


This worked PERFECTLY. Thanks!

u're welcome :) I'm glad it helped someone :)

Good lookin' flora01, thanks for the good tip. I was about to start writing some recursive scripts, etc. etc. using a single parent ID. This one does the job as well.


i solved my problem by using your code.

I edited latest product module. Somehow, they works.


[0] Message Index

[#] Next page

Go to full version