Author Topic: How to show latest products first in each category.  (Read 4464 times)

prylstad

  • Jr. Member
  • **
  • Posts: 102
How to show latest products first in each category.
« on: July 28, 2010, 16:11:31 pm »
As the title says I want the latest products to be shown first and furthest up instead of what it is doing now.

"Latest products" is selected in each category but the oldest one are highest up and the latest lowest down.

I want to reverse this if possible.
Does anyone know how?

EDIT: STILL NOT SOLVED!

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #2 on: July 29, 2010, 13:54:02 pm »
I did it. However it does not seem like it solved it for me! Thank you for a fast reply thgouh. Any ideas on what could be the problem?

Also I found the code on line 55

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #3 on: July 29, 2010, 13:56:43 pm »
This is how it looks like now on line 55:



$orderby = $vmInputFilter->safeSQL( $vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}orderby", 'orderby', VM_BROWSE_ORDERBY_FIELD )); // If sorting by "Latest Products" and user didn't specify a Sorting Order, make it Descending (to show newest products first)
if( $orderby == 'product_cdate' && !$vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy' ) ) {
   $DescOrderBy = 'DESC';
}

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: How to show latest products first in each category.
« Reply #4 on: July 29, 2010, 17:08:04 pm »
prylstad, that solution assumes that in your config, the "Default Product Sort Order" is "Latest Products".  If you wish to always force "Latest Products" to be newest first, change the first part of the "if" statement to
     if( $orderby == 'product_cdate' ) {

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #5 on: July 29, 2010, 17:16:06 pm »
I changed it to this:


$orderby = $vmInputFilter->safeSQL( $vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}orderby", 'orderby', VM_BROWSE_ORDERBY_FIELD )); // If sorting by "Latest Products" and user didn't specify a Sorting Order, make it Descending (to show newest products first)
if( $orderby == 'product_cdate' ) { && !$vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy' ) ) {
   $DescOrderBy = 'DESC';
}


Is this correcT?

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #6 on: July 29, 2010, 17:19:21 pm »
It is still not working.

Tell me exactly what to do please, as I am a noob!

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #7 on: July 29, 2010, 17:27:53 pm »
Also "latest products" are chosen in vm config as default!

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #8 on: August 06, 2010, 11:30:46 am »
Sorry for double posting. But the other thread has been marked solved so I have to type in here instead.

Here is my msg:


Allright. I understand that solution2 assumes that in my vm config default product sort order is "latest products". It is in my config!

ok
This is solution 2:


// If sorting by "Latest Products" and user didn't specify a Sorting Order, make it Descending (to show newest products first)
if( $orderby == 'product_cdate' && !$vm_mainframe->getUserStateFromRequest( "browse{$keyword}{$category_id}{$manufacturer_id}DescOrderBy", 'DescOrderBy' ) ) {
   $DescOrderBy = 'DESC';
}


When you say change the first part of the
"if" statement to
" if( $orderby == 'product_cdate' ) {"

I do not really understand how far I am going to replace it so please show exactly where i should put that line in.

Yes I want it to always be showing latest products first!

prylstad

  • Jr. Member
  • **
  • Posts: 102
Re: How to show latest products first in each category.
« Reply #9 on: October 13, 2010, 00:44:40 am »
IT seems to work now:D