0

I have overridden the AccountController of customer for a functionality which will redirect user to a specific page after checkout login.
For which I had to pass some parameter to the _loginPostRedirect() method as follows..

My override functions..

public function loginPostAction()
{
 if ($this->_getSession()->isLoggedIn()) {
 $this->_redirect('*/*/');
 return;
 }
 $session = $this->_getSession();
 if ($this->getRequest()->isPost()) {
 $login = $this->getRequest()->getPost('login');
 .......
 .......
 .......
 .......
 }
 .......
 .......
 $this->_loginPostRedirect($login); //here I have passed the parameter
} 
protected function _loginPostRedirect($login)
{
 .....
 .....
 .....
 if(isset($login['isMobCheckout'])){
 $this->_redirectUrl($login['isMobCheckout']);
 }
 else{
 $this->_redirectUrl($session->getBeforeAuthUrl(true));
 }
}

So when I execute this the following error is coming..

Strict Notice: Declaration of Newcustom_Customer_AccountController::_loginPostRedirect() should be compatible with Mage_Customer_AccountController::_loginPostRedirect()

So I have passed the same variable in the core functions even if there is no use, And then it works fine.

But I did modify the core file which will be a problem while upgrading the system.

Could anyone please suggest whether it will be alright or is there any other methods present for doing the above functionality to avoid modify in core methods ?

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
asked Apr 29, 2016 at 4:46
2
  • declare your parameters in global level and set them in loginPostAction() function and use them in _loginPostRedirect($login) function without passing as parameters Commented Apr 29, 2016 at 5:32
  • Hi @Charlie, 1. The parameters are retrieve from POST request as $login = $this->getRequest()->getPost('login'); It is only a value of a hidden field which is checked for the redirection. So could you help me how to set them as global variable ? Commented Apr 29, 2016 at 5:38

2 Answers 2

1
public $parameters = null; // global declaration
public function loginPostAction()
{
 if ($this->_getSession()->isLoggedIn()) {
 $this->_redirect('*/*/');
 return;
 }
 $session = $this->_getSession();
 if ($this->getRequest()->isPost()) {
 $login = $this->getRequest()->getPost('login');
 $this->_parameters=$this->getRequest()->getPost('login'); //define
 .......
 .......
 .......
 .......
 }
 .......
 .......
 $this->_loginPostRedirect($login); //here I have passed the parameter
} 
protected function _loginPostRedirect($login)
{
$login = $this->_parameters; // use here as you want
 .....
 .....
 .....
 if(isset($login['isMobCheckout'])){
 $this->_redirectUrl($login['isMobCheckout']);
 }
 else{
 $this->_redirectUrl($session->getBeforeAuthUrl(true));
 }
}
answered Apr 29, 2016 at 5:52
2
  • It is working fine @Charlie. Thanks. How to acquire these type of tricks for developers ? Commented Apr 29, 2016 at 6:45
  • everyone solve the problem differently so you need to check and look in to other code style. how they write it, what is their strategy to achieve solution... Commented Apr 29, 2016 at 8:28
0

Hope this will Help You ...

In your app\code\local\Override\Accountcntrlr\controllers\Customer\Accountcntrlr.php

<?php
require_once "Mage/Customer/controllers/AccountController.php"; 
class Override_Accountcntrlr_Customer_AccountController extends Mage_Customer_AccountController{
 public function loginPostAction()
 {
 if ($this->_getSession()->isLoggedIn()) {
 $this->_redirect('*/*/');
 return;
 }
 }
}

In app\code\local\Override\Accountcntrlr\etc\config.xml

 <?xml version="1.0"?>
<config>
 <modules>
 <Override_Accountcntrlr>
 <version>0.1.0</version>
 </Override_Accountcntrlr>
 </modules>
 <frontend>
 <routers>
 <accountcntrlr>
 <use>standard</use>
 <args>
 <module>Override_Accountcntrlr</module>
 <frontName>accountcntrlr</frontName>
 </args>
 </accountcntrlr>
 </routers>
 </frontend>
 <global>
 <rewrite> 
 <override_accountcntrlr_customer_accountcontroller>
 <from><![CDATA[#^/customer/account/#]]></from> <!-- Mage_Customer_AccountController -->
 <to>/accountcntrlr/customer_account/</to> <!-- Override_Accountcntrlr_Customer_AccountController -->
 </override_accountcntrlr_customer_accountcontroller>
 </rewrite>
 <helpers>
 <accountcntrlr>
 <class>Override_Accountcntrlr_Helper</class>
 </accountcntrlr>
 </helpers>
 </global>
 <admin>
 <routers>
 <accountcntrlr>
 <use>admin</use>
 <args>
 <module>Override_Accountcntrlr</module>
 <frontName>admin_accountcntrlr</frontName>
 </args>
 </accountcntrlr>
 </routers>
 </admin>
</config> 

In app\etc\modules\Override_Accountcntrlr.xml

<?xml version="1.0"?>
<config>
 <modules>
 <Override_Accountcntrlr>
 <active>true</active>
 <codePool>local</codePool>
 <version>0.1.0</version>
 </Override_Accountcntrlr>
 </modules>
</config>
answered Apr 29, 2016 at 6:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.