仅显示特价产品

发布于 2025-02-05 04:24:03 字数 176 浏览 3 评论 0原文

是否可以仅显示特殊价格的产品?

我将{%如果product.special%}放在我的product_card.twig中,那效果很好,但是我的分页无法正常工作。它仍然显示属于该类别的产品总数。

我在某些类别中有5种产品,但分页说“显示9(1页)中的1到9个”。

还有其他方法可以实现这一目标吗?

Is it possible to show only products with special prices?

I put {% if product.special %} in my product_card.twig, and that works fine but then my pagination doesn't work correctly. It still shows the total number of products that belongs to that category.

I have 5 products in some category but pagination says "Showing 1 to 9 of 9 (1 pages)".

Is there any other way to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈场末日恋爱 2025-02-12 04:24:03

您应该创建新的模型函数,从DB获取查询

public function getSpecialByCategory() {
   // your query here
}

,并通过控制器获得结果,然后控制器将其发送到您的树枝文件。

You should create new model function that get query from DB some thing like

public function getSpecialByCategory() {
   // your query here
}

and get result by controller then controller send it to your Twig file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文