VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: slammy on November 02, 2015, 17:54:28 PM

Title: case latest in models/product.php with RAND()
Post by: slammy on November 02, 2015, 17:54:28 PM
Hi Community,

yet on vm 3.0.10 and jml 3.4.5 - everybody who wants to have random-ordering (because of many new products) for latest products module on vm-frontpage should use this code for case 'latest' in
/administrator/components/com_virtuemart/models/product.php


case 'latest':
$date = JFactory::getDate (time () - (60 * 60 * 24 * $latest_products_days));
$dateSql = $date->toSQL ();
$where[] = 'p.`' . $latest_products_orderBy . '` > "' . $dateSql . '" ';
//$orderBy = 'ORDER BY p.`' . $latest_products_orderBy . '`';
$orderBy = 'ORDER BY RAND() ';
break;



instead of original code


case 'latest':
/*$date = JFactory::getDate (time () - (60 * 60 * 24 * $latest_products_days));
$dateSql = $date->toSQL ();
$where[] = 'p.`' . $latest_products_orderBy . '` > "' . $dateSql . '" ';*/
//vmdebug('product model ',$latest_products_orderBy);
$orderBy = 'ORDER BY p.`' . $latest_products_orderBy . '` ';

$this->filter_order_Dir = 'DESC';
break;


best regards
jens
Title: Re: case latest in models/product.php with RAND()
Post by: Milbo on November 02, 2015, 18:11:11 PM
lol, you just set back, what was there. The whole time filter is nonsense. If a shopowner is not updating his products for longer time than $latest_products_days, you see no products anylonger.
Title: Re: case latest in models/product.php with RAND()
Post by: slammy on November 02, 2015, 18:18:26 PM
hey thats right, but if you update your shop with cvs-import as example - all 3 month a hundred products and edit them - this module is static in ordering because it shows always the same products in the same order and if you show as an example 3 lines with 4 products in a row you have 12, but there are eightyeight others which are new too ...
Title: Re: case latest in models/product.php with RAND()
Post by: Milbo on November 02, 2015, 18:47:12 PM
The reason for that rand()
Title: Re: case latest in models/product.php with RAND()
Post by: PRO on November 02, 2015, 21:47:42 PM
slammy,
but why hack the core though?


mod_virtuemart_product.php

Increase,   $max_items
$products = $productModel->getProductListing($Product_group, $max_items, $show_price, true, false,$filter_category, $category_id);

then rand & limit on the front end.

Title: Re: case latest in models/product.php with RAND()
Post by: slammy on November 02, 2015, 22:04:25 PM
Hey Hutson,

thanks for your hint with mod_virtuemart_product.php, I didn“t knew I can do it this way too.
Always nice here to speak to the pros, my learning curve is always high ... ;)
best regards
jens
Title: Re: case latest in models/product.php with RAND()
Post by: PRO on November 02, 2015, 22:07:15 PM
Ok,
But I'm not Hutson

Title: Re: case latest in models/product.php with RAND()
Post by: slammy on November 02, 2015, 22:14:39 PM
Of course, sorry PRO
Title: Re: case latest in models/product.php with RAND()
Post by: AH on November 03, 2015, 09:51:13 AM
I'll take the praise - although I have changed my profile name to AH

;)
Title: Re: case latest in models/product.php with RAND()
Post by: slammy on November 03, 2015, 17:12:04 PM
aaah now I get it - you fooled me man! Today - not mainly but partly - I was thinking about why I thought your username was Hutson and I think it was because of an similiar avatar-image I noticed at the gui-side last years by post from Hutson. Taking a look into the function "search members" offers me the solution :) If I had read your last post yesterday truly you gave me the hint already. Cheers ;)