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.
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
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
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() .
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.
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?
Is it possible to make it that you can sort the featured products by SKU?
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.
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.