News:

Support the VirtueMart project and become a member

Main Menu

case latest in models/product.php with RAND()

Started by slammy, November 02, 2015, 17:54:28 PM

Previous topic - Next topic

slammy

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

Milbo

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

slammy

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

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

PRO

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.


slammy

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

PRO


slammy


AH

#8
I'll take the praise - although I have changed my profile name to AH

;)
Regards
A

Joomla 4.4.5
php 8.1

slammy

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 ;)