After adding a few products in my Magento 18.104.22.168 site, I have found that the latest added product will go to the last of the product list. That doesn’t make sense. So… I googled it for finding the solution but almost of them are hacking the Magento’s core code. This will cause my website some problems when upgrade Magento in the future.
The right solution is try to config Magento using layout files.
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 red 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>
After that upload this file to your server. However, don’t forget to clear Magento’s cache unless you will see the result.
You may change method attribute’s value to an another one. This value is the name of methods of class Mage_Catalog_Block_Product_List_Toolbar [click here for the complete API document]. And also you can change the value of dir block (<dir>…</dir>) which is the argument name and its value of the method
CK Rock @ comment #59 of this thread
9 replies on “Sort product by newest in Magento (with out hacked!)”
ใช้ Magento ทำอะไรเนี่ย ตอนนี้กะลังดูเล่นอยู่เหมือนกัน
ทำ E-Commerce ให้บริษัทรุ่นน้องอะครับ
This worked perfect. Thank you very much! – Magento 22.214.171.124
Brilliant – just what I’ve been looking for – much nicer to edit xml code rather than the core files!
Great trick ! Thx for the tip !!!
thank you.work great on my site with version 1.7.02.But the catalog.xml is located in Base folder.it is better to copy it to the sub-theme’s folder that which your website are using.
@Ribbons Great to here that it still works with 1.7, also thank you for the suggestion, I absolutely agree with you.
Great! This also worked on Magento 126.96.36.199 🙂 Thanks !!!
Is there a way to just want to change the default value (0) of the “product listing sort by” Best Value, to a higher value?