Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从新产品列表中排除缺货产品-Prestashop_Prestashop_Prestashop 1.6 - Fatal编程技术网

从新产品列表中排除缺货产品-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比修改它更好

我希望这能有所帮助