Search Term Redirect URL – Relative Path Instead of Full URL Path?

magento-1.7magento-1.8magento-enterprisesearch

When editing a Search Query, why doesn't Magento allow the Redirect URL to be Relative Paths like /section/subsection or /best-product. It enforces the full URL which is kind of pain. How would you change this and is there any reasons to consider not changing this?

Magento Documents its Search Term Redirect Functionality.

Best Answer

A quick test by removing the JS validation validate-url seemed to work without any issues for me, so with that in mind:

/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php:

In function _prepareForm()

Change this:

$fieldset->addField('redirect', 'text', array(
    'name'  => 'redirect',
    'label' => Mage::helper('catalog')->__('Redirect URL'),
    'title' => Mage::helper('catalog')->__('Redirect URL'),
    'class' => 'validate-url',
    'note'  => Mage::helper('catalog')->__('ex. http://domain.com'),
));

To this:

$fieldset->addField('redirect', 'text', array(
    'name'  => 'redirect',
    'label' => Mage::helper('catalog')->__('Redirect URL'),
    'title' => Mage::helper('catalog')->__('Redirect URL'),
    //'class' => 'validate-url',
    //'note'  => Mage::helper('catalog')->__('ex. http://domain.com'),
));

NOTE: obviously do not just edit core but extend the Adminhtml Block.

Related Topic