如何按产品编号获取类别列表?
我需要按产品编号对类别进行排序,这意味着哪个类别拥有大量产品将显示在类别列表的顶部。因此类别列表应按产品编号降序排列。 任何帮助将不胜感激!
我的类别及其产品如下:
category no of products
cell phones 5
cameras 8
computers 3
我想按产品编号对类别相机、手机、计算机进行排序。对于此排序结果,我想使用加入集合类类别。
I need to sort categoies by product number that means which category has large number of products is shown at the top of category list. So catgories list should be descending order by product number.
any help would be appreciated!
I have categories and its product as following as:
category no of products
cell phones 5
cameras 8
computers 3
I would like to sort categories cameras,cell phones,computers by product number .For this sorting result i would like to use join in collection class of category.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下代码将获取每个类别的产品:-
您可以这样做:-
希望这有帮助。谢谢。
The following code will fetch the product per category:-
You can do in this way:-
Hope this helps. Thanks.
如果您有一个名为
$collection
的类别集合,那么您可以执行以下操作:编辑:
要使其成为覆盖集合中的默认值,请使用以下方法:
If you have a collection of categories called
$collection
then you can do this:Edit:
To make it the default in an overridden collection use this method: