I need to have recently added sort by option how can I get this.I searched google and also SE's but cannot found the solutions but not worked.
1 Answer
To get recently added sort by option open app/code/core/Mage/Catalog/Block/Product/List/toolbar.php
and find and replace the below code will be in line 232
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
return $this;
by
if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='recentlyadded'){
$this->_collection->setOrder('entity_id','desc');
}
else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}
return $this;
also in line no 391
find and replace this code
public function setDefaultOrder($field)
{
if (isset($this->_availableOrder[$field])) {
$this->_orderField = $field;
}
return $this;
}
with this code
public function setDefaultOrder($field) {
if (isset($this->_availableOrder[$field])) {
$this->_availableOrder = array(
'recentlyadded' => $this->__('Recently Added'),
'name' => $this->__('Name'),
'price' => $this->__('Price'),
);
$this->_orderField = $field;
}
return $this;
}
this should help you in getting the required recently added functionality if any queries please let me know.
-
-
-
Integrity constraint violation: 1052 Column 'parent_item_id' in where clause is ambiguous Mar 28, 2016 at 5:29
-
@dh47, how can we show this option only for specific categories? Jun 3, 2019 at 14:00
-
@dh47, this will not load if any color and size filters are present, Nov 5, 2019 at 12:01