1

In Magento 1.9 I was facing this issue on all the product listing pages as the links generated were like (catalog/product/view/id/123), which I have managed to change to product url by setting "Use Web Server Rewrites" to yes.

But now I need if someone enters the url (catalog/product/view/id/123) then it should also be redirected to (product-name.html)

1

I was finally able to achieve this by creating an observer for event http_response_send_before

Following is the code in observer:

$currentUrl = Mage::helper('core/url')->getCurrentUrl();
if (strpos($currentUrl, 'catalog/product/view/id') !== false) {
    $params = Mage::app()->getRequest()->getParams();
    $seo_url = Mage::getBaseUrl().Mage::getResourceSingleton('catalog/product')->getAttributeRawValue($params['id'], 'url_key', Mage::app()->getStore());
    Mage::app()->getResponse()->setRedirect($seo_url);
}

Hope this will be helpful for others.

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.