Для использования сфинкса заменить в classes\Search .php функцию find
Код:
public static function find($id_lang, $expr, $pageNumber = 1, $pageSize = 1, $orderBy = 'position', $orderWay = 'desc', $ajax = false)
    {
        global $cookie;
        $db = Db::getInstance(_PS_USE_SQL_SLAVE_);
        // TODO : smart page management
        if ($pageNumber < 1) $pageNumber = 1;
        if ($pageSize < 1) $pageSize = 1;
        if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay))
            die(Tools::displayError());
//==========sphinx fix===============
include('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer( "localhost", 9312 );
$cl->SetMatchMode( SPH_MATCH_ANY  );
$result = $cl->Query($expr);
if (!$result)
    return false;
$eligibleProducts = $result["matches"];
if (empty($eligibleProducts))
    return false;
        $productPool = '';
        foreach ($eligibleProducts AS $product=>$info)
            if (!empty($product))
                $productPool .= (int)$product.',';
        if (empty($productPool))
            return ($ajax ? array() : array('total' => 0, 'result' => array()));
        $productPool = ((strpos($productPool, ',') === false) ? (' = '.(int)$productPool.' ') : (' IN ('.rtrim($productPool, ',').') '));
//==================================
        if ($ajax)
        {
            if (!$result = $db->ExecuteS('
            SELECT DISTINCT p.id_product, pl.name pname, cl.name cname,
                cl.link_rewrite crewrite, pl.link_rewrite prewrite '.$score.'
            FROM '._DB_PREFIX_.'product p
            INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
            INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.')
            WHERE p.`id_product` '.$productPool.'
            ORDER BY position DESC LIMIT 10'))
                return false;
            return $result;
        }
        $queryResults = '
        SELECT SQL_CALC_FOUND_ROWS p.*, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`, pa.`id_product_attribute`,
            tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.', DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new
        FROM '._DB_PREFIX_.'product p
        INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                   AND tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                      AND tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
        WHERE p.`id_product` '.$productPool.'
        '.($orderBy ? 'ORDER BY  '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
        LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize;
        $result = $db->ExecuteS($queryResults);
        $total = $db->getValue('SELECT COUNT(*)
        FROM '._DB_PREFIX_.'product p
        INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                   AND tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                      AND tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
        WHERE p.`id_product` '.$productPool);
        
        return array('total' => $total,'result' => Product::getProductsProperties($id_lang, $result));
    }
Это код для версии 1.4. sphinxapi.php должен лежать в той же папке
Сообщение отредактировано ors  25-04-2011 20:52 ...