简体   繁体   English

如何在magento中禁用带有搜索词的自动重定向?

[英]how to disable automatic redirect with search term in magento?

I need to disable magento's core function that does the main catalog search redirect. 我需要禁用执行主要目录搜索重定向的magento的核心功能。

Ie: http://peachepe.gostorego.com/ 即: http//peachepe.gostorego.com/

enter search term: Test 输入搜索词:测试

if it is the default search box that you are talking about, on top of the page, then have a look at some of the code at /app/code/core/Mage/CatalogSearch/controllers/ResultController.php and see what happens there. 如果这是您要讨论的默认搜索框,请在页面顶部,查看/app/code/core/Mage/CatalogSearch/controllers/ResultController.php上的一些代码,并查看发生了什么。

it handles the basics of where that page should go, after a catalog search. 在目录搜索之后,它处理了该页面应去向的基础知识。

/**
 * Catalog Search Controller
 */
class Mage_CatalogSearch_ResultController extends Mage_Core_Controller_Front_Action
{
    /**
     * Retrieve catalog session
     *
     * @return Mage_Catalog_Model_Session
     */
    protected function _getSession()
    {
        return Mage::getSingleton('catalog/session');
    }
    /**
     * Display search result
     */
    public function indexAction()
    {
        $query = Mage::helper('catalogsearch')->getQuery();
        /* @var $query Mage_CatalogSearch_Model_Query */

        $query->setStoreId(Mage::app()->getStore()->getId());

        if ($query->getQueryText()) {
            if (Mage::helper('catalogsearch')->isMinQueryLength()) {
                $query->setId(0)
                    ->setIsActive(1)
                    ->setIsProcessed(1);
            }
            else {
                if ($query->getId()) {
                    $query->setPopularity($query->getPopularity()+1);
                }
                else {
                    $query->setPopularity(1);
                }

                if ($query->getRedirect()){
                    $query->save();
                    $this->getResponse()->setRedirect($query->getRedirect());
                    return;
                }
                else {
                    $query->prepare();
                }
            }

            Mage::helper('catalogsearch')->checkNotes();

            $this->loadLayout();
            $this->_initLayoutMessages('catalog/session');
            $this->_initLayoutMessages('checkout/session');
            $this->renderLayout();

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

I just had to replace 我只需要更换

if ($query->getRedirect()){
        $query->save();
        $this->getResponse()->setRedirect($query->getRedirect());
       return;
    }
    else {
        $query->prepare();
    }

with

$query->prepare();

或只是转到数据库中的“ catalogsearch_query”表,并确保没有一个名称使用重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM