根据在 magento 中添加的日期对类别进行排序
在我的magento项目中..我想根据custom_design_from或custom_design_to对所有产品类别进行排序....
就像
最新添加的类别必须首先连续显示一样..根据堆栈概念,
任何人都可以帮我吗..我怎样才能在页面上显示类别。
谢谢! 里查
In my magento project..I want to sort all product category according to custom_design_from or custom_design_to....
like
latest added category must be display at first in a row than so on..as according to stack concept
can anyone please help me out..how can I do display categories on the page.
Thanks!
Richa
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望获取网站中的所有类别并按创建日期对它们进行排序,那么您可以使用以下内容:
您可能希望通过明确说明来替换 ->addAttributeToSelect('*')您想要恢复的属性 - 只是为了加快速度。
我根据您的要求在这里使用了 DESC,但您也可以使用 ASC 来达到相反的效果。
上面的代码将为您提供整个集合。要获得实际的类别,您需要使用如下所示的内容迭代该集合:
这应该为您提供一个很好打印的每个类别创建日期的列表。
要获取每个类别的更多信息,您可以使用 $category->getName()、$category->getId() 等。你明白了。
此代码很可能会放入您的块或帮助程序中,您可以将其包装在一个函数中,您可以从模板中调用该函数来访问所需的类别信息。
希望这有帮助。
if you are looking to grab all of the categories in your site and order them by the date they were created then you can use something along the lines of:
You will probably want to replace ->addAttributeToSelect('*') by explicitly stating the attributes you want back - just to speed things up a little.
I have used DESC here as per your request but you could also use ASC for the opposite effect.
The code above will give you a whole collection. To get to the actual categories you will need to iterate over that collection with something like the following:
This should give you a nicely printed out list of dates that each category was created.
To get more info on each category you can use things like $category->getName(), $category->getId() and so on. You get the idea.
This code will more than likely go in your block or helper and you can wrap it in a function which you will be able to call from your template to get access to the required category information.
Hopefully this helps.
在简单的 PHP 脚本中,只需使用 MySql Select Query 即可完成。
根据 Megento Pattarn 使用此 SQL 选择查询:
检查此希望对您有所帮助。
In simple PHP script it can be done by simply using MySql Select Query.
Use this SQL Select Query According to Megento Pattarn :
Check this hope it will helpfull to you.