Reputation: 41
I have a question about how to show only products that are in stock in a certain category in Prestashop. The other categories must show products out of stock and products in stock but this one only in stock.
I try to edit the function getProducts in Category.php and change the line:
WHERE product_shop.id_shop
= '.(int)$context->shop->id.'
to:
WHERE stock.quantity
> 0 AND product_shop.id_shop
= '.(int)$context->shop->id.'
It doesn't worked and also I don't know where to put this query in order to only affects to this category.
Any idea about what I'm doing wrong?
Upvotes: 0
Views: 538
Reputation: 1447
Do you get an error? try to use "quantity" instead of "stock.quantity".
Also you should check id_category after $sql:
$sql = 'something';
if ($this->id == $targetCategoryId) { // $targetCategoryId can replace by configuration: Configuration::get('YOUR_CUSTOM_CATEGORY_ID')
$sql .= 'AND WHERE quantity > 0';
}
Upvotes: 0