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

Hack to use randomprod module for multiple categories

(1/2) > >>

flora01:
Hello,
This tip is inspired from this post:
http://forum.virtuemart.net/index.php?topic=21242.0

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
or,
(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!)

then:
go to this file:
/modules/mod_virtuemart_randomprod/mod_virtuemart_randomprod.php

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 ---
then

--- 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:
Code:

1,2

--- 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

Regards

nd:
This worked PERFECTLY. Thanks!

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

joseugs:
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.

oceanb702:
hi,

i solved my problem by using your code.

http://forum.virtuemart.net/index.php?topic=97795.0

I edited latest product module. Somehow, they works.

Navigation

[0] Message Index

[#] Next page

Go to full version