English 中文(简体)
Magento: 如何分类产品收集?
原标题:Magento: How to sort product collection?
  • 时间:2012-01-15 13:25:52
  •  标签:
  • magento

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?

在铺设了约50个床铺并试图研究之后,我实际上几乎 st了。

提前感谢。

最佳回答

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 );

过滤你需要做的类别

$productCollection = Mage::getModel( catalog/category )->load($categoryId);

然后,你可以确定这种秩序。

问题回答

暂无回答




相关问题
Magento addFieldToFilter allow NULLs

When using the Magento collection method addFieldToFilter is it possible to allow filtering by NULL values? I want to select all the products in a collection that have a custom attribute even if no ...

Get product link from Magento API

I am new to Magento and using their API. I need to be able to get the product url from the API call. I see that I can access the url_key and url_path, but unfortunately that s not necessarily what ...

magento extension installation

I want to install a Magento extension in WAMP, but not from the Magento connect system. How can I do this? I have the module (extension) code and I already installed the sample data in the Magento ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

How do I filter a collection by a YesNo type attribute?

I have a ‘featured’ attribute, which has a Yes/No select-list as the admin input. I presume that the values for Yes and No are 1 and 0, as they are for every other Yes/No list. However, if I try and ...

热门标签