Magento currently does not sort category products and any product listing for that matter by Newest (highest entity_id). Since my store works best when showing fresh products we felt it necessary to have our Magento installation sort by newest product first (descending) so that just by clicking through categories, users would be seeing the latest and greatest products. Now, Magento does allow you to manually rank per product from the Catalog -> Manage Categories -> Category Products screen, but changing our product listings to show latest products first was our goal.
I was able to change my Magento product listings to show newest items first by following the comments in this post within the Magento Forum:
The two important pieces are here:
We need things sorted by product entered date since my industry is very front-line driven. So I wen and changed things to this:
$this->_availableOrder = array(
‘entity_id’ => $this->__(’Newest’),
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’)
);
And here:
Figured it out: in the same toolbar.php file, around lines 101-110, change this:
public function getCurrentDirection()
{
if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) {
$dir = strtolower($dir);
if (in_array($dir, array(’desc’, ‘asc’))) {
return $dir;
}
}
return ‘asc’;
}To this:
public function getCurrentDirection()
{
if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) {
$dir = strtolower($dir);
if (in_array($dir, array(’desc’, ‘asc’))) {
return $dir;
}
}
return ‘desc’;
}Along with your ‘newest’ entity_id it works like a charm!
That allowed me to have my Magento store sort by newest product first.
Now, there will be an issue when updating so hopefully they’ll be able to add default sort ordering to the administrative suite in the upcoming versions.
9 Responses
narina
March 21st, 2009 at 10:15 pm
1very good! thanks a lot!!
Einstein9
September 23rd, 2009 at 2:40 am
2Well, i wanted to thank you for this tip, but i tried to open the file and search for the string to replace it but i could not find it.
i dono if the magento ver. makes a difference
mine is: 1.3.2.3
is there any other way please?
or can i pay someone to fix this for me?
thank you
SonicE
October 19th, 2009 at 7:38 am
3For Magento version 1.3.2.3
The file you need to look at is: /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php Since we’ll modify it, make a copy to /app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
Near Line 98 search for
protected $_direction = ‘asc’;
Change to
protected $_direction = ‘desc’;
y
November 4th, 2009 at 7:21 am
4i was just looking for this! will try out!
Daniel
January 21st, 2010 at 4:21 am
5Can’t find anywhere the code for:
$this->_availableOrder = array(
‘entity_id’ => $this->__(’Newest’),
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’)
);
ed
January 21st, 2010 at 2:09 pm
6Daniel, the file would be here:
/app/code/core/Mage/Catalog/Block/Product/List.php
Skully
February 12th, 2010 at 8:29 am
7Could not find any of these lines in mine either 2 files.
$this->_availableOrder = array(
‘entity_id’ => $this->__(’Newest’),
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’)
);
Magento ver. 1.3.2.3
ed
February 14th, 2010 at 10:28 am
8Skully, I’m running the same version and the file for this is still on the Product List.php template:
/app/code/core/Mage/Catalog/Block/Product/List.php
steward
March 6th, 2010 at 4:37 pm
9This discussion assumes “entity_id” means the same as “newest”.
Not so, for many who imported and updated some batches of products when we converted to Magento.
I’d really like to sort by “date added”. Sigh.
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Clients and Projects
Recently Written
Calendar
Recent Entries
Recent Comments
Most Commented
Kliky.Net - Web Development Blog is proudly powered by WordPress - BloggingPro theme by: Design Disease