datasn.io
datasn.io

Reputation: 12867

Making a custom sort method the default one on Magento category pages?

I followed the instructions from the first answer of this question: Magento - Sort by Date Added

And I successfully added the sort method Date for my Magento store: http://www.princessly.com/wedding-apparel/wedding-dresses/

My question is, how can I make it (Date) the default sort method and descending as the default order for all my categories? So that the newest products are at the beginning of the page. For now, 'position' is the default sort method and the default order is ascending.

Thus far I tried to modify config.xml and System -> Configuration -> Catalog -> Frontend -> Product Listing Sort by but there's no 'Date' option at all, just 'Best Value', 'Name', 'Price'. So my question can also be addressed by adding 'Date' in this drop-down so that I can select it?

How?

Thanks!

Upvotes: 2

Views: 5973

Answers (2)

Shatir
Shatir

Reputation: 613

For setting the date as your default sort method you'd have to edit the function getCurrentOrder() located at app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php .

You can refer to this link.

But I think it is for older releases.

EDIT:

I haven't tried it but you could also refer to this link, look in the comments section there's a reply for setting date as the default method.

Upvotes: 1

liyakat
liyakat

Reputation: 11853

In this case, product ordering, you have to open “catalog.xml” in the layout folder. Then in the following code block, you just add the setDefaultDirection line in order to change the default sorting direction to descending.

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
 <block type="page/html_pager" name="product_list_toolbar_pager"/>
  <!-- The following code shows how to set your own pager increments -->
 <!-- .... -->
 <action method="setDefaultDirection"><dir>desc</dir></action>
 </block>

Upvotes: 0

Related Questions