从新产品列表中排除缺货产品-Prestashop
我正在使用一个模块,在主页中显示新添加的产品。我需要自定义模块,以便此列表不包含已销售的产品。换言之,如果一个产品在购买新产品的天数结束之前就已经缺货,那么就不要在列表中显示该产品 我可以通过使用从新产品列表中排除缺货产品-Prestashop,prestashop,prestashop-1.6,Prestashop,Prestashop 1.6,我正在使用一个模块,在主页中显示新添加的产品。我需要自定义模块,以便此列表不包含已销售的产品。换言之,如果一个产品在购买新产品的天数结束之前就已经缺货,那么就不要在列表中显示该产品 我可以通过使用{if$product.quantity
{if$product.quantity<0}{/if}
在视图部分中执行它,但我的目标是在控制器中执行它。这是我的密码:
function hookHome($params)
{
global $smarty, $cookie;
$nb = intval(Configuration::get('HOME_NEW_PRODUCTS_NBR'));
$rand = intval(Configuration::get('HOME_NEW_PRODUCTS_RANDOM'));
if ($rand == 1) {
$products = Product::getNewProducts(intval($cookie->id_lang), 0, $nb);
if ( $products )
{
shuffle($products);
array_slice($products, ($nb ? $nb : 10));
}
}
else
{
$products = Product::getNewProducts(intval($cookie->id_lang), NULL - 0, (intval($nb ? $nb : 4)), false, NULL, NULL);
}
$smarty->assign(array(
....
'products' => $products,
....
);
return $this->display(__FILE__, 'homenewproducts.tpl');
}
如何重写类Product
,以便方法getNewProducts
考虑排除缺货的产品
或者至少,如何使用PHP从$products
中删除数量为0的产品
非常感谢您的帮助。我现在使用的解决方案是: 在
product.php
中,我更改了NewProductsController
中getNewProducts
方法中的sql查询,以便考虑产品是否有库存
我添加了和“数量”=第2062行中的0和('p.'quantity'!=0')代码>在第2086行。Prestashop 1.6.0.6
当然,重写classe Product.php比修改它更好
我希望这能有所帮助