News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Product Module - Latest Products - Sort by creation date descending

Started by charly_81, December 19, 2011, 21:15:09 PM

Previous topic - Next topic

charly_81

Hello,
I'm using the product module with option "Latest Products" and I'm a little bit confused about its current behaviour.
What I had expected was, that the first product that gets displayed by the module is the one that I had most recently created(!). However, the module seems to fetch the configured amount of products depending on the date when the product has recently been modified(!). Furthermore I had expected that "latest" products get displayed with DESCENDING date and not the other way round!  ???

I managed to adjust the module's behaviour, but therefore I had to change VM core file "products.php" (administrator/components/com_virtuemart/models) around line 362: 

case 'latest':
/*$date = JFactory::getDate( time()-(60*60*24*7) ); //Set on a week, maybe make that configurable*/
$date = JFactory::getDate( time()-(60*60*24*7*8) );             /*a week was not enough for me-->make it 8 weeks!*/
$dateSql = $date->toMySQL();
                                        /*$where[] = 'p.`modified_on` > "'.$dateSql.'" '; */
$where[] = 'p.`created_on` > "'.$dateSql.'" ';                  /*show products depending on creation date!*/
$orderBy = ' ORDER BY p.created_on  ';                          /*new: changed sort criteria to creation date!*/
$this->filter_order_Dir = 'DESC';                               /*new: show the most recently created product first!*/
break;


To development team: as you already mentioned in your coding comments  ;) it would be a nice feature if the considered timespan could be made configurable. Maybe you can also make the selection and sorting criteria configurable?

Nevertheless: KEEP UP THE GOOD WORK! VM2 is an awesome application! :D

Best regards,
Charly

mark001

Not sure if this is related with product.php file but I noticed the same problem VirtueMart Home Page.
Also, no matter how many products I added it always shows only 5 products for Latest Products and for Top Ten products.

Also, in the Products module I noticed there is a problem with CSS classes /modules/mod_virtuemart_product/tmpl/default.php line 16:

<div style="<?php echo $float ?>" class="<?php echo $pwidth ?>">

If layout is set to div based I'm getting this:

<div style="floatleft" class="width33">

In my override I changed this to:

<div class="<?php echo $float ?><?php echo $pwidth ?>">

PRO


jasonmccullars

I am using VM 2.0.10.  I would like for "sort by price" to default to ascending order.  what file do I manipulate?