Reputation: 91
i have created a list_home.phtml that i call from {{block type="catalog/product_list" category_id="6" template="catalog/product/list_home.phtml"}}
The category is very important because i will have 3 tabs in this homepage slider.
This is a version of the product list without toolbar to include in a homepage slider, where the user should never be able to change the sorting.
However in the main catalog there is the toolbar. Currently, if the user changes the sorting there and then goes back to the homepage the sort order on the home page will also be affected!
How can i force the $collection to always sort by newest and also filter the category from the frontend's block call?
I am really almost stuck after opening around 50 tabs in the broswer and trying to research, really need some help here please.
Thanks in advance.
Upvotes: 1
Views: 9149
Reputation: 1704
On the product collection you can set the order by calling ->setOrder
on it.
I'm not sure of the field you would need to order by, but if you wanted to set it by price ascending you would do
->setOrder('price', 'ASC');
To filter the category you need to do this
$productCollection = Mage::getModel('catalog/category')->load($categoryId);
You can then set the sort order
Upvotes: 5