VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: filtheetees on April 10, 2012, 05:47:23 AM

Title: 2.0.4 stable Featured Product Bug
Post by: filtheetees on April 10, 2012, 05:47:23 AM
Updating from 2.0.2 stable to 2.0.4 stable has caused the featured products to change positions every time the page is refreshed.
Title: Re: 2.0.4 stable Featured Product Bug
Post by: John2400 on April 10, 2012, 06:42:13 AM
Hi filtheetees,

just wondering if this is good or not - it looks like an added feature as you could have 20 featured products but only 3 or 6 fit at the bottom of the page and then they rotate around.

Maybe not an error - just a new feature
Title: Re: 2.0.4 stable Featured Product Bug
Post by: filtheetees on April 11, 2012, 05:07:23 AM
For mine I usually have 9 featured that do not move - had to edit the code to increase the 5 shown to 9

As of 2.0.4 none of them stay in the same position

Maybe it was intentional from dev I did not see any patch notes though
Title: Re: 2.0.4 stable Featured Product Bug
Post by: teobgeno on April 11, 2012, 05:32:03 AM
I noticed on

administrator/components/com_virtuemart/models/product.php Line 314


// special  orders case
switch ($this->filter_order) {
case 'product_special':
$where[] = ' p.`product_special`="1" ';// TODO Change  to  a  individual button
$orderBy = 'ORDER BY RAND()';
break;



There are 2 more ORDER BY RAND() in this file.
ORDER BY RAND() shuffles randomly the return result of the query on every request and that's why the change of products positions in frontend.
I have not yet test feautures products so i don't know for sure which from 3 ORDER BY RAND() should change in administrator/components/com_virtuemart/models/product.php . I am not sure either if there is an option to admin to disable random ordering. In conclusion that is not a bug but a normal functionality of
ORDER BY RAND() .

Title: Re: 2.0.4 stable Featured Product Bug
Post by: Milbo on April 12, 2012, 00:21:18 AM
Imho I did this on purpose yes. Exactly as said, before it showed all the time the same featured products. Which is not meant that way. It is meant so that you have for example a bigger store with 10k products. You have a campaign every week and you want to push 20 products or so.
Title: Re: 2.0.4 stable Featured Product Bug
Post by: filtheetees on April 13, 2012, 04:09:02 AM
Ah ok I did not realise this was intentional

So just deleting
'ORDER BY RAND()'
will stop it from changing its order if I do want featured to stay the same?

Title: Re: 2.0.4 stable Featured Product Bug
Post by: woogygun on July 09, 2012, 14:51:04 PM
Is it possible to make it that you can sort the featured products by SKU?
Title: Re: 2.0.4 stable Featured Product Bug
Post by: Dan1980 on July 31, 2013, 03:51:23 AM
Hi woogygun,

I know this is an old thread, but I thought this would help others out there who had to work it out on their own. To do this with VM2, you go to:

public_html/administrator/components/com_virtuemart/models/product.php

Around line 362 change RAND() to `product_sku` so that it appears like this:

$orderBy = 'ORDER BY `product_sku`';

And around line 411 change RAND() to `product_sku` so that it appears like this:

$orderBy = 'ORDER BY `product_sku`';

Please make sure that you surround `product_sku` with the right characters. It is not the apostrophe, it is the Grave Accent. Find this in your Character Map (U+0060 Grave Accent). On your keyboard it should by the one prior to the number 1 above QWERTY (it's the same one that when done as Shift+` will give tilde ~)

Hope this helps someone.
Title: Re: 2.0.4 stable Featured Product Bug
Post by: cas on September 28, 2013, 00:57:12 AM
It sure would be nice to have this as an option in the module admin so we can select either product order or random order.