2015-06-02 62 views
0

我只達到:的Prestashop搜索

$results = $db->executeS(' 
     SELECT cp.`id_product` 
     FROM `'._DB_PREFIX_.'category_product` cp 
     '.(Group::isFeatureActive() ? 'INNER JOIN `'._DB_PREFIX_.'category_group` cg ON cp.`id_category` = cg.`id_category`' : '').' 
     INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` 
     INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` 
     '.Shop::addSqlAssociation('product', 'p', false).' 
     WHERE c.`active` = 1 
     AND product_shop.`active` = 1 
     AND product_shop.`visibility` IN ("both", "search") 
     AND product_shop.indexed = 1 
     '.$sql_groups);  

我試圖改變查詢類/ search.php中,但一切都沒有改變。幫我。

回答

0

我做了一個數組,你要使用過濾器搜索類的ID:

$fitersArray = array (//put the category you want filter); 
$activeFilterString = implode($fitersArray, ','); 


$results = $db->executeS(' 
     SELECT cp.`id_product` 
     FROM `'._DB_PREFIX_.'category_product` cp 
     '.(Group::isFeatureActive() ? 'INNER JOIN `'._DB_PREFIX_.'category_group` cg ON cp.`id_category` = cg.`id_category`' : '').' 
     INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` 
     INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` 
     '.Shop::addSqlAssociation('product', 'p', false).' 
     WHERE c.`active` = 1 
     AND product_shop.`active` = 1 
     AND product_shop.`visibility` IN ("both", "search") 
     AND c.`id_category` IN (' . $activeFilterString .') 
     AND product_shop.indexed = 1 
     '.$sql_groups);