: This article mainly introduces how to make Magento's newly uploaded products appear at the top of the category Display List ?, If you are interested in the PHP Tutorial, refer. In the actual environment, this situation occurs. after a product is added, but on the product display page, the first added is always in front, and the last added is sometimes displayed on pages, this is because magento products are listed in ascending order by default. that is to say, the first added products are always displayed at the beginning, and the last added products are listed at the end. If we want to sort the last added products in the descending order, how can we modify them?
First Open the following directory file:
File: \ app \ code \ core \ Mage \ Catalog \ Block \ Product \ List \ Toolbar. php,
Find
Protected $ _ direction = 'asc ';
This parameter is the default order.
Modify:
Protected $ _ direction = 'desc ';
Save the settings.
You can also think through the following methods. Magento assigns a unique ID value to a product each time a product is uploaded, and the IDs are sorted by auto-Increment 1, the display method sorts the last uploaded items in descending order of IDs.
Modify the current Toolbar. php
Find:
$ This-> _ collection-> setOrder ($ this-> getCurrentOrder (), $ this-> getCurrentDirection ());
Changed:
$ This-> _ collection-> setOrder ($ this-> getCurrentOrder (), $ this-> getCurrentDirection ()-> setOrder ('entity _ id ', 'desc ');
You can.
The above describes how to make Magento's newly uploaded products display at the top of the category display ?, Including some content, hope to be helpful to friends who are interested in PHP tutorials.