Reputation: 3721
I've tried this and it partially works
http://www.dconstructing.com/2011/04/07/sort-magento-catalog-by-date-added/
But on a page that has multiple categories, it sorts categories as first level, and only then it sorts products within each category.
So an earlier product in a category comes before a later product in another category. I don't want that. I want a flat sorting that only sorts by "position" (magento term) regardless of the category.
How can I achieve that?
Upvotes: 1
Views: 7546
Reputation: 301
Step 1: To Achieve this copy the file Toolbar.php
from app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
. Create a Directory Structure in local and paste the Toolbar.php
as shown below app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
Step 2: Around line 232 you should see the below code in setCollection()
function
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
Replace the above code with the new code given below
if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='position'){
$this->_collection->setOrder('entity_id','desc');
}
else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}
Upvotes: 0
Reputation: 155
This instruction work for me with the same problem product sorting. I used the third one Magento Sort by Newest Products Solution
Upvotes: 1
Reputation: 2790
Alternatively to Guerra's answer, while inside toolbar.phtml you can use:
<?php if($this->getCurrentDirection() == 'desc') : ?>
<?php $this->addOrderToAvailableOrders('created_at','Newest') ?>
<?php else : ?>
<?php $this->addOrderToAvailableOrders('created_at','Oldest') ?>
<?php endif; ?>
Upvotes: 0