2015-09-26 51 views
1

如何獲得產品的條件,例如,所有產品0數量? 我使用getProducts函數,但沒有條件選項。的Prestashop - 把產品與條件

/** 
* Get all available products 
* 
* @param integer $id_lang Language id 
* @param integer $start Start number 
* @param integer $limit Number of products to return 
* @param string $order_by Field for ordering 
* @param string $order_way Way for ordering (ASC or DESC) 
* @return array Products details 
*/ 
public static function getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false, 
    $only_active = false, Context $context = null) {...} 

我想到了get後添加條件,但在佔用更多的資源:

$products = $category->getProducts($this->context->language->id, 1, 100); 
$condition_products; 
foreach ($products as $key => $product) 
{ 
    if (condition) 
    { 
     $condition_products .= $product 
    } 
} 

回答

1

如果你不想檢查迴路數量,可能overridegetProducts方法和添加您需要的任何條件。