Magento Expert Forum - Improve your Magento experience

Results 1 to 3 of 3

Redirects for Product Pages

  1. #1

  2. #2
    Junior Member MageWorxTeam's Avatar
    Join Date
    Sep 2014
    Location
    Washington, DC
    Posts
    52
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Rob Caswell View Post
    Hi!

    I want to delete some products from my store. The only problem that I don't want my customers to see the page not found error. How can I deal with this? Maybe any extension supports this functionality?

    I'm using M1. Many thanks.
    To set up 301/ 302 redirects for your old product pages, you may consider SEO Suite Ultimate extension for Magento:


    http://www.mageworx.com/seo-suite-ul...extension.html


    The extension will let you create these types of redirects for your old product pages and thus avoid 'page not found' errors.

    Also, with the extension you can specify the time period to keep redirects on your site, manage all deleted product redirects and more.

  3. #3
    Expert
    Join Date
    Mar 2016
    Location
    india
    Posts
    570
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Hi,
    Redirects for Product Pages
    Observer.php:

    class Namespace_Mymodule_Model_Observer {
    public function redirect(){
    //request object
    $request = Mage::app()->getRequest();
    //only redirect in the frontend/catalog
    $storeId = Mage::app()->getStore()->getId();
    if(in_array($request->getModuleName(), array("catalog")) && $storeId != 0) {
    $response = Mage::app()->getResponse();
    $params = Mage::app()->getRequest()->getParams();
    //check the product id
    if($params[id] == 10) {
    return $response->setRedirect("/mymodule", 301)->sendHeaders();
    }
    }
    }
    }

    And the config.xml in the global/events section:

    <controller_action_predispatch>
    <observers>
    <namespace_mymodule_observer>
    <type>singleton</type>
    <class>namespace_mymodule/observer</class>
    <method>redirect</method>
    </namespace_mymodule_observer>
    </observers>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •