繁体   English   中英

仅显示特定类别的库存中的产品

[英]Show only products in stock of certain category Prestashop

我有一个问题,关于如何仅显示Prestashop中某个类别中库存的产品。 其他类别必须显示缺货的产品和有库存的产品,但此类别仅在库存中。

我尝试在Category.php中编辑功能getProducts并更改行:

在product_shop。 id_shop ='。(int)$ id_shop > shop-> id。'

至:

库存在哪里。 quantity > 0 AND product_shop。 id_shop ='。(int)$ id_shop > shop-> id。'

它不起作用,而且我也不知道在哪里放置此查询,以便仅影响此类别。

关于我在做什么错的任何想法吗?

收到错误消息吗? 尝试使用“数量”而不是“ stock.quantity”。

另外,您应该在$ sql之后检查id_category:

$sql = 'something';
if ($this->id == $targetCategoryId) { // $targetCategoryId can replace by configuration: Configuration::get('YOUR_CUSTOM_CATEGORY_ID')
    $sql .= 'AND WHERE quantity > 0';
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM