Hello,
I have a Joomla 3.8.11 website with Virtuemart 3.2.14 website.
I am using a menu item with "Top level category" setting to display all available products in my shop.
When i go to vm-> Config -> Product order settings, currently "Default product sort order" is set to "Ordering, name" order. But there is no setting as "random".
I know there is product module that can be used to show random products, but i can't use it as already there is override used for that module to show products in carousel. So, that option is not available.
So, can anyone help me achieve this? I can make changes to core file if needed but i am not sure which file to edit.
So, any help will be much appreciated.
Thanks.
administrator\components\com_virtuemart\models\product.php
function sortSearchListQuery()
somewhere there.. maybe even the parameter $group - try 'random'
see code if ($group) { ~ line 623
Perhaps my module https://shop.st42.fr/en/products/products-any-ways.htm
Thank you very much for the replies.
Quote from: GJC Web Design on November 08, 2018, 23:12:54 PM
administrator\components\com_virtuemart\models\product.php
function sortSearchListQuery()
somewhere there.. maybe even the parameter $group - try 'random'
see code if ($group) { ~ line 623
@GJC Web Design:
Thank you very much for taking to right file. The suggested change was not working as it took me to "//Group case from the modules". So, probably, that group case is for vm product module. I wanted it for component. So, i searched in the same file & successfully randomized product order.
For those who are looking for this, please note that, i have a vm store in catalog mode. So, i went to :
vm-> Config -> Product order settings and used "Default product sort order" to "Ordering" (not Ordering, Name)
Then in administrator\components\com_virtuemart\models\product.php
in function sortSearchListQuery, at line number 535, look for comment
// special orders caseas i chose 'Ordering' in vm config, i went to line number 564 where we have
case 'pc.ordering':
$orderBy = ' ORDER BY `pc`.`ordering` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;
$joinCategory = TRUE;
break;
I changed this to:
case 'pc.ordering':
$orderBy = 'ORDER BY RAND()';
$joinCategory = TRUE;
break;
So, if you choose any other sort setting like Product name or Product price in vm config, you will have to make changes in respective switch case.