I try to overwrite a function from a core class without having to create an extra extension for it.
I need to overwrite the function _loginPostRedirect()
from Mage_Customer_AccountController
to change the redirect behaviour.
The class is in app\code\core\Mage\Customer\controllers\AccountController.php
Im not sure about the fall-back way of magento, but I remember I readed that magento first looks in app\code\local\
instead of app\code\core
to find out if the file exists there and then app\code\local\Mage\Customer\controllers\AccountController.php
is getting loaded instead of app\code\core\Mage\Customer\controllers\AccountController.php
.
But I tried it and magento still loads the file from app\code\core
.
How does it work?
Basically I just want to change one line at the very bottom:
/**
* Define target URL and redirect customer after logging in
*/
protected function _loginPostRedirect()
{
$session = $this->_getSession();
if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
// Set default URL to redirect customer to
$session->setBeforeAuthUrl($this->_getHelper('customer')->getAccountUrl());
// Redirect customer to the last page visited after logging in
if ($session->isLoggedIn()) {
if (!Mage::getStoreConfigFlag(
Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
)) {
$referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
if ($referer) {
// Rebuild referer URL to handle the case when SID was changed
$referer = $this->_getModel('core/url')
->getRebuiltUrl( $this->_getHelper('core')->urlDecodeAndEscape($referer));
if ($this->_isUrlInternal($referer)) {
$session->setBeforeAuthUrl($referer);
}
}
} else if ($session->getAfterAuthUrl()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
}
} else {
$session->setBeforeAuthUrl( $this->_getHelper('customer')->getLoginUrl());
}
} else if ($session->getBeforeAuthUrl() == $this->_getHelper('customer')->getLogoutUrl()) {
$session->setBeforeAuthUrl( $this->_getHelper('customer')->getDashboardUrl());
} else {
if (!$session->getAfterAuthUrl()) {
$session->setAfterAuthUrl($session->getBeforeAuthUrl());
}
if ($session->isLoggedIn()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
}
}
// $this->_redirectUrl($session->getBeforeAuthUrl(true));
$this->_redirectUrl("/customer/account");
}
app\code\core\Mage\Core\Model\Resource\Setup.php
toapp\code\local\Mage\Core\Model\Resource\Setup.php
and edited it, but the original is still getting loaded.