Magento:如何对产品集合进行分类? [英] Magento: How to sort product collection?

查看:57
本文介绍了Magento:如何对产品集合进行分类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个我从{{block type="catalog/product_list" category_id="6" template="catalog/product/list_home.phtml"}}调用的list_home.phtml.该类别非常重要,因为在此主页滑块中将有3个选项卡.
这是产品列表的版本,其中没有工具栏包括在首页滑块中,用户永远不能更改其排序.
但是,在主目录中有工具栏.当前,如果用户在此处更改排序,然后返回首页,则主页上的排序顺序也将受到影响! 如何强制$ collection始终按最新排序,并从前端的阻止调用中过滤类别?

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个标签并尝试进行研究之后,我真的差点被困住了,请在这里确实需要一些帮助.

I am really almost stuck after opening around 50 tabs in the broswer and trying to research, really need some help here please.

谢谢.

推荐答案

在产品集合上,您可以通过在其上调用->setOrder来设置订单. 我不确定您是否需要订购该字段,但是如果您想按价格升序进行设置

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

这篇关于Magento:如何对产品集合进行分类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆