3

After upgrading the magento search is not working.

I tried this https://magento.stackexchange.com/a/67952

SELECT e.*, search_result.relevance, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position FROM catalog_product_entity AS e INNER JOIN catalogsearch_result AS search_result ON search_result.product_id=e.entity_id AND search_result.query_id='43' INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 INNER JOIN catalog_category_product_index AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id = '2'

Result:

Array (
    [class] => Mage_CatalogSearch_Model
    [resourceModel] => catalogsearch_resource
    [rewrite] => Mage_Core_Model_Config_Element Object
        (
            [layer_filter_attribute] => WeltPixel_LayeredNavigation_Model_CatalogSearch_Layer_Filter_Attribute
        ) 
)

When I checked the tables, I can find that catalogsearch_result table seems always empty. But catalogsearch_query and catalogsearch_fulltext tables have content.

Why this table shows empty? How can I fix that?

  • 2
    Have you tried the solution ? – Anil Suthar May 4 '17 at 17:17
1

In Magento 1.9.3.x, catalogsearch_result table is NO longer used I think.

There are minor differences/changes in CatalogSearch module in 1.9.3.x and 1.9.0.x versions.

You can check app\code\core\Mage\CatalogSearch\Model\Fulltext.php, here NEW property _foundData is added which holds FullText search results instead saving in catalogsearch_result table.

Check prepareResult method of both versions,

In 1.9.3.x versions,

$this->_foundData = $adapter->fetchPairs($select, $bind);

In 1.9.0.x versions,

$sql = $adapter->insertFromSelect($select,
    $this->getTable('catalogsearch/result'),
    array(),
    Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE);
$adapter->query($sql, $bind);

What should be done now (for 1.9.3.x versions) ?

You can use getFoundData method of this class to get results :

$searchText = STRING_TO_SEARCH;
$query = Mage::getModel('catalogsearch/query')->loadByQueryText($searchText);
if($query->getId()){
    $fulltextResource = Mage::getResourceModel('catalogsearch/fulltext')->prepareResult(
        Mage::getModel('catalogsearch/fulltext'), 
        $query->getQueryText(), 
        $query
    );
    $prod_ids = $fulltextResource->getFoundData();
    //print_r($prod_ids);
}

Here $prod_ids is an Array variable which contains Product Id and No. of count as Key=>Value pair.

1

Try run re-index Go to the system menu and index management.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.