1

how can i set the search keyword (input by customer) default display to "NO" in magento backend so i can moderate the suggested search keyword below the searchbar?

2

The quick and dirty way is to change the column display_in_terms of the catalogsearch_query table to default to 0 instead of 1.

The long and clean way is to rewrite the method Mage_CatalogSearch_ResultController::indexAction() and replace this:

if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
    $query->save();
}

with this:

if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
    if (!$query->getId()) { //if is a new search word
         $query->setDisplayInTerms(0); //don't display it in search terms.
    }
    $query->save();
}
| improve this answer | |
  • Where can I find this code? – paddotk Sep 28 '15 at 15:09
  • in app/code/core/Mage/CatalogSearch/controllers/ResultController.php – Marius Sep 28 '15 at 15:23
1

I'am allowing myself to give a slight modification for the answer above as for magento 1.7.0.2 the code was not working.

Indeed the condition is not working because an Id is automatically attributed before in the code on line 14.

if (Mage::helper('catalogsearch')->isMinQueryLength()) {
            $query->setId(0)
                ->setIsActive(1)
                ->setIsProcessed(1);
} 

Therefore the interpreter never enter into the condition.

For myself I did the following. I added a bit of code at the beginning of the method

At line 12 I added the following

if ($query->getQueryText() != '') {

            /* Added code */
            $newsearchterm = false; //creation of a boolean
            if (!$query->getId()) { 
                $newsearchterm=true; // if the there is no id we set to true
            }
            /* End Added code by */

            if (Mage::helper('catalogsearch')->isMinQueryLength()) {
                $query->setId(0)
                    ->setIsActive(1)
                    ->setIsProcessed(1);
            }

And then at below I added

if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
                // Added code 
                if ($newsearchterm) { //if is a new search word (boolean true)
                    $query->setDisplayInTerms(0); //don't display it in search terms.
                }
                // End of added code 
                $query->save();
            }

Finnally I would like to add that you cannot override a controller, but you will have to rewrite it. So it means the creation of a little module for making it work.

Thanks and don't hesitate to suggest any code improvements.

Have a great day,

| improve this answer | |
-1

app/code/core/Mage/CatalogSearch/Model/Resource edit file : Fulltext.php

just change this line $likeCond = ‘(‘ . join(‘ OR ‘, $like) . ‘)’; $likeCond = ‘(‘ . join(‘ AND ‘, $like) . ‘)’;

| improve this answer | |
  • Welcome to Magento SE. It looks like you answered the wrong question. This is a solution for a completely different problem. Please check again – Fabian Schmengler Jul 27 '17 at 14:46
  • It's forbidden to update the Magento core ! – PЯINCƏ Jul 27 '17 at 15:51

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.