How can Magento bring the newly uploaded products to the forefront of category display?

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.