How to edit the sorting order of New Products displayed on Magento homepage
-
19-12-2019 - |
문제
I am showing new products on homepage with the code
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
Now the results are shown from the oldest to newest.
How can i configure the ascending / descending, so i can see the newest to oldest ?
해결책
Welcome to Magento.SE! This is quite easy to do and will require that you make a module to rewrite the functionality of Mage_Catalog_Block_Product_New
.
Once you've done that, you need to just make an edit to the _getProductCollection
method modifying the collection:
protected function _getProductCollection()
{
$collection = parent::_getProductCollection();
$collection->addAttributeToSort('news_from_date', 'desc');
return $collection;
}
제휴하지 않습니다 magento.stackexchange