2

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.

1 Answer 1

2

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.

4
  • One question. You said you tested this. Did having a relative path seem to effect the redirection functionality?
    – JustinP
    Commented May 30, 2014 at 10:55
  • It was a simple spot check, but appeared to work without issue. I'm not sure the specifics why they chose absolutes vs relative, so testing the above would be best.
    – B00MER
    Commented May 30, 2014 at 15:59
  • 1
    This officially works in production. I made a module. If anyone is interested, let me know.
    – JustinP
    Commented Jun 5, 2014 at 17:38
  • put it up on github please.
    – David
    Commented Aug 12, 2015 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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