How to make Magento newly uploaded products in the category show the front?

Source: Internet
Author: User
In the actual environment, you will encounter this situation, each time the product is added, but in the product display page, the first addition is always in front, and then added sometimes need to page, to see, this is because Magento products in the list page by default is sorted in ascending order, that is, the first product is always displayed in the front, And the latter is added in turn at the end. If we want to add the last product to the front, that is, in reverse order, how to modify it?
First open the following directory file:
file:\app\code\core\mage\catalog\block\product\list\toolbar.php,
Found it

protected $_direction = ' ASC ';
This parameter is the default order
Modified to:
protected $_direction = ' desc ';
and then save.
Can also be thought through the following methods, Magento each upload a product, will give the product a unique ID value, and the ID value of the order is self-added 1, so, the display can be based on the last item uploaded, in reverse order to sort by ID.
Also modifies the current toolbar.php
Found it:

$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());

Switch

$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection())->setOrder('entity_id', 'desc');

Can.

The above describes how to let Magento newly uploaded products in the category display the front? , including the aspects of the content, want to be interested in PHP tutorial friends helpful.

  • Related Article

    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.