0

When i edit my account information in "customer/account/edit", after submits it goes to my account page. I need the form to stay in same page after submitting and saving information. In my module config.xml i made a redirect:

<frontend>
    <events>
        <controller_action_postdispatch_customer_account_editPostAction>
            <observers>
              <customerredirect>
                <class>customerredirect/observer_customer</class>
                <method>editRedirect</method>
              </customerredirect>
            </observers>
        </controller_action_postdispatch_customer_account_editPostAction>
    </events>
</frontend>

Then in Model -> Observer -> Customer.php i have the function:

   public function editRedirect(Varien_Event_Observer $observer){
      $url = Mage::getUrl('sales/order/history');
      Mage::app()->getResponse()->setRedirect($url);
      return $this;
    }

If i change

controller_action_postdispatch_customer_account_editPostAction

into

controller_action_postdispatch_customer_account_edit

it redirects account edit page into sales history. But what i want to redirect is after form submits. I'm also trying to redirect my account inital page "customer/account" to "sales/order/history" page, but this method it's not working when i put controller_action_postdispatch_customer_account.

Any ideas?

1

You have to simply rewrite a app/code/core/Mage/Customer/controllers/AccountController.php, editPostAction() in your local codePool, then change this :

...
try {
    $customer->cleanPasswordsValidationData();
    $customer->save();
    $this->_getSession()->setCustomer($customer)
         ->addSuccess($this->__('The account information has been saved.'));
    $this->_redirect('customer/account');
    return;
...

to:

...
    try {
        $customer->cleanPasswordsValidationData();
        $customer->save();
        $this->_getSession()->setCustomer($customer)
             ->addSuccess($this->__('The account information has been saved.'));
        $this->_redirect('*/*/edit');
        return;
...

Then after submit, he save a new data and return the same page.

| improve this answer | |
  • It's not working. I tried before editing the AccountController.php in app/code/local/Mage/Customer/controllers/AccountController.php but for some reason it doesn't redirect. It's like the file is being overriden by another file/extension. I already tried searching in plugins/modules without success. – JonnyDevv Aug 29 '17 at 10:15
  • Ah Ok, the solution works i tried it and i confirm, however if you have rewrited it, you have to find it in your app/code/local or community if you have installed an extension. – PЯINCƏ Aug 29 '17 at 10:28
0

Why controller_action_postdispatch_customer_account_editPostAction not worked

In order to understand the why controller_action_postdispatch_customer_account_editPostAction is not worked then You should check Mage_Core_Controller_Varien_Action's at method dispatch($action)

In magento, there are all the events by application defined and at every page dispatch there are few events call automatically like

Mage::dispatchEvent( 'controller_action_postdispatch_'.$this->getFullActionName(), array('controller_action'=>$this) );

As per as this logic,magento is create an event controller_action_postdispatch_customer_account_edit on customer/account/edit's postdispatch().

The full Action name of this URL is customer_account_edit .$this->getFullActionName() give this fullaction Name of this url.

As we know that customer/account/edit mean routername/ActioName/Actionname

  • Route name is customer As frontend name customer
    account

  • Controller file is AccountController.php that why Action name account

  • Action Method is editAction() that why Action name edit

controller_action_postdispatch_customer_account_editPostAction

So, it editaccountinfo's event name is

controller_action_postdispatch_customer_account_editPost


"customer/account" is event name is

controller_action_postdispatch_customer_account_index

| improve this answer | |
  • This redirect worked. Only problem is keeping session messsages like success messages. BTW, thanks for the explanation. :) – JonnyDevv Aug 29 '17 at 10:38

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.