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.