0

The idea is to keep the form in catalogsearch/advanced/

and to post the result to catalogsearch/advanced/result/

without all parameters added by the get method.

What are the necessary changes to have toolbar working ?

Thanks

2

You need to do two things here.

1. Change Form Method to POST

File : app\design\frontend\{package|\{theme}\template\catalogsearch/advanced/form.phtml

<form action="<?php echo $this->getSearchPostUrl() ?>" method="post" id="form-validate">

Here we just changed form action method to POST.

2.Rewrite controller Mage_CatalogSearch_AdvancedController

To do this in proper way, you have to create a small module. Let me call it as MagentoSE_CatalogSearch.

File : app\code\local\MagentoSE\CatalogSearch\etc\config.xml

<?xml version="1.0"?>
<config>
    <frontend>
        <routers>
            <catalogsearch>
                <args>
                    <modules>
                        <magentose_catalogsearch before="Mage_CatalogSearch">MagentoSE_CatalogSearch</magentose_catalogsearch>
                    </modules>
                </args>
            </catalogsearch>
        </routers>
    </frontend>
</config>

File : app\code\local\MagentoSE\CatalogSearch\controllers\AdvancedController.php

<?php
require_once(Mage::getModuleDir('controllers','Mage_CatalogSearch').DS.'AdvancedController.php');

class MagentoSE_CatalogSearch_AdvancedController extends Mage_CatalogSearch_AdvancedController
{
    public function resultAction()
    {
        $this->loadLayout();
        try {
            Mage::getSingleton('catalogsearch/advanced')->addFilters($this->getRequest()->getPost());
        } catch (Mage_Core_Exception $e) {
            Mage::getSingleton('catalogsearch/session')->addError($e->getMessage());
            $this->_redirectError(
                Mage::getModel('core/url')
                    ->setQueryParams($this->getRequest()->getPost())
                    ->getUrl('*/*/')
            );
        }
        $this->_initLayoutMessages('catalog/session');
        $this->renderLayout();
    }
}

Change here is obvious. Instead of $this->getRequest()->getQuery(), we are now using $this->getRequest()->getPost() to fetch form data correctly.

  • Thanks for your answer. Can you please give changes needed to have toolbar working properly ? Actually not working with changes given in your answer. – vhanahrni Jun 21 '16 at 8:21
  • @Jordan My answer is just hint. You need to have min. knowledge about Magento module development. You should study it if not. This is a platform to learn, not a platform to get code snippets or extension :) – Rajeev K Tomy Jun 21 '16 at 9:16
  • I agree with you. what I know is that get method send parameters to url and toolbar.php return current url with rewrites and additional parameters. As post method don't send parameters to url, toolbar.php need changes. – vhanahrni Jun 21 '16 at 18:14

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.