News:

Support the VirtueMart project and become a member

Main Menu

2.0.4 stable Featured Product Bug

Started by filtheetees, April 10, 2012, 05:47:23 AM

Previous topic - Next topic

filtheetees

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.

John2400

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

filtheetees

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

teobgeno

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() .


Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

filtheetees

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?


woogygun

Is it possible to make it that you can sort the featured products by SKU?

Dan1980

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.

cas

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.