Showing posts with label Display recently added product in magento. Show all posts
Showing posts with label Display recently added product in magento. Show all posts

Monday, 14 December 2015

How to Display the recently added products first in Magento?

 Display the recently added products first in Magento


Please copy the file Toolbar.php from 


app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

And  Create a Directory structure in local and paste the Toolbar.php as shown below 

app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php

and Find the below code at around line 232


if ($this->getCurrentOrder()) {
  $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}


Now Replace the above code with below code:

if ($this->getCurrentOrder()) {
  if(($this->getCurrentOrder())=='position'){
      $this->_collection->setOrder('entity_id','desc');
  }
  else {
   $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
  }
}