本文介绍了Magento 1.9注册后重定向客户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento 1.9中成功注册后,我想将所有客户重定向到自定义页面.

I would like to redirect all customers to a custom page after successful registration in Magento 1.9.

我尝试了很多事情.首先,我成功地重载了核心客户帐户控制者.

I have tried many things. Firstly, I am successfully overriding the core customer account controller.

我尝试自定义以下操作:

I have attempted to customize the following actions:

  • createPostAction
  • _successProcessRegistration
  • _welcomeCustomer

通过尝试设置重定向URL或通过设置BeforeAuthUrl

By trying to set redirect url or by setting BeforeAuthUrl

    //$successUrl = $this->_getUrl('*/*/index', array('_secure' => true));
    $successUrl = $this->_getUrl('*/*/success');
    $this->_getSession()->setBeforeAuthUrl('http://test.local/customer/account/success/');
    if ($this->_getSession()->getBeforeAuthUrl()) {
        $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
    }
    return $successUrl;

请注意,此时$ successUrl返回此处是正确的.我看到有一些我认为是后期的Dispatch方法正在扭曲此URL,并始终返回到客户/帐户/索引.

Please note at this point, $successUrl is correct when it returns here. I see there are some post Dispatch methods that I am assuming are destorying this url and always returning to customer/account/index.

我已经阅读了有关该主题的几篇文章,找不到解决该问题的明确答案.

I have read several posts on this topic and cannot find a definitive answer that solves this question.

我甚至设置了隐藏的表单元素'success_url',以尝试遵循在其他地方提出的解决方案.

I have even set hidden form element 'success_url' in attempts to follow steps presented elsewhere as solutions to this.

要显示一次性注册成功页面,需要遵循的完整,正确的过程是什么?

What is the full, correct process that one needs to follow in order to be able to show a one time registration success page?

推荐答案

如果要执行this for customer successfully then you can do this using 事件观察器

在客户successfully magento trigger事件customer_register_success

这将调用一个观察者,该观察者将重新请求到托管页面

This call an observer which will reequestion to custtom page

  Mage::app()->getResponse()->setRedirct($Yourdreicurll);

详细信息:

第1步:创建config.xmlapp/code/community/Amit/Custommodule/etc/-有关更多信息,请参见: http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/#sthash.JSktrUD0.dpuf 和它的代码

Step1:create config.xml is app/code/community/Amit/Custommodule/etc/ - See more at: http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/#sthash.JSktrUD0.dpufand it code

<?xml version="1.0" ?>
<config>
    <modules>
        <Amit_Custommodule>
            <version>1.0.0</version>
        </Amit_Custommodule>
    </modules>
    <global>
        <models>
            <custommodule>
                <class>Amit_Custommodule_Model</class>
            </custommodule>
        </models>
    </global>
    <frontend>
      <events>
          <customer_register_success>
        <observers>
          <notify_user>
            <class>custommodule/observer</class>
            <method>myredirection</method>
          </notify_user>
        </observers>
          </customer_register_success>
        </events>
    </frontend>
</config>

第二步:

在app/etc/modules/中创建模块控制文件,模块名为Amit_Custommodule.xml

create module control file Module name as Amit_Custommodule.xml at app/etc/modules/

它的代码是

<?xml version="1.0"?>
<config>
    <modules>
        <Amit_Custommodule>
            <codePool>community</codePool>
            <active>true</active>
        </Amit_Custommodule>
    </modules>
</config>

第3步:

在Amit> Custommodule> Model上创建observer.php

Create observer.php at Amit>Custommodule>Model

代码是

 <?php
    class Amit_Custommodule_Model_Observer {
        public function myredirection(Varien_Event_Observer $observer) {
        $AccountController = $observer->getEvent()->getAccountController();

        $Customer = $observer->getEvent()->getCustomer();

         $response1 = Mage::app()->getResponse(); // observers have event args

            $url = 'http://www.example.com/';
            $response1->setRedirect($url);
            Mage::app()->getFrontController()->sendResponse();

        return;
      }
    }

这篇关于Magento 1.9注册后重定向客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:26