2

I want to redirect to home on customer login and i don't want to work this redirection on checkout login
here is my code /app/etc/modules/Cusredirection_customer.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Cusredirection_customer>
            <active>true</active>
            <codePool>local</codePool>
        </Cusredirection_customer>
    </modules>
</config>

app/code/local/Cusredirection/customer/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Cusredirection_customer>
            <version>0.0.1</version>
        </Cusredirection_customer>
    </modules>
    <global>
        <models>
            <cusredirection_customer>
                <class>Cusredirection_customer_Model</class>
            </cusredirection_customer>
        </models>
        <events>
            <customer_login>
              <observers>
                  <cusredirection_customer>
                      <class>cusredirection_customer/observer</class>
                      <method>customerLogin</method>
                      <type>singleton</type>
                  </cusredirection_customer>
              </observers>
            </customer_login>
        </events>
    </global>
</config>

app/code/local/Cusredirection/customer/Model/observer.php

<?php
class Cusredirection_customer_Model_Observer
{
    public function setRedirectOnLogin(){
        $session = Mage::getSingleton('customer/session');
        if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') === false)
            $session->setAfterAuthUrl(Mage::getBaseUrl());  
        else             
            $session->setAfterAuthUrl(Mage::helper('core/http')->getHttpReferer());

        $session->setBeforeAuthUrl('');
    }
}
?>

1 Answer 1

2

Your folder name customer should be Customer

change as per this

here is my code /app/etc/modules/Cusredirection_Customer.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Cusredirection_Customer>
            <active>true</active>
            <codePool>local</codePool>
        </Cusredirection_Customer>
    </modules>
</config>

app/code/local/Cusredirection/Customer/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Cusredirection_Customer>
            <version>0.0.1</version>
        </Cusredirection_Customer>
    </modules>
    <global>
        <models>
            <cusredirection_customer>
                <class>Cusredirection_Customer_Model</class>
            </cusredirection_customer>
        </models>
        <events>
            <customer_login>
              <observers>
                  <cusredirection_customer>
                      <class>cusredirection_customer/observer</class>
                      <method>setRedirectOnLogin</method>
                      <type>singleton</type>
                  </cusredirection_customer>
              </observers>
            </customer_login>
        </events>
    </global>
</config>

app/code/local/Cusredirection/Customer/Model/observer.php

<?php
class Cusredirection_Customer_Model_Observer
{
    public function setRedirectOnLogin(){
        $session = Mage::getSingleton('customer/session');
        if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') === false)
            $session->setAfterAuthUrl(Mage::getBaseUrl());  
        else             
            $session->setAfterAuthUrl(Mage::helper('core/http')->getHttpReferer());

        $session->setBeforeAuthUrl('');
    }
}
?>
4
  • I have changed as per your suggestion but the problem is still there . While login as customer it going to account page
    – amith lal
    Mar 7, 2017 at 9:15
  • @Amith check updated code in config.xml Mar 7, 2017 at 9:19
  • No change still it going to customer/account/index/ page
    – amith lal
    Mar 7, 2017 at 9:36
  • @ Murtuza Is there any other way to do this using any other event?
    – amith lal
    Mar 8, 2017 at 4:24

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.