【问题标题】:How would you add a step in the AccountController of Magento?您将如何在 Magento 的 AccountController 中添加一个步骤?
【发布时间】:2011-03-30 21:33:21
【问题描述】:

我需要在 Magento 模板中添加一个跟踪代码,这很简单,但是当用户注册时我需要在确认页面上使用它,但是当它这样做时,他会被重定向到索引页面,就像任何登录的用户一样。

我想通过覆盖帐户控制器来添加一个步骤,因为没有这样的配置(或者我找不到它),但即使它只是一个方法覆盖 confirmAction 来处理重定向,它也不会看起来是最好的方法,因为这个重定向会根据几件事被调用多次并添加会话消息。

有什么想法吗?

【问题讨论】:

    标签: zend-framework magento controller overriding


    【解决方案1】:

    我知道你可以做到这一点的唯一真正方法是挂钩controller_action_postdispatch_customer_account_createPost 事件。如果您不知道该怎么做,请查看this Wiki page

    在你的观察者中,做这样的事情:

    // Store a simple boolean that flags this user as just having registered
    Mage::getSingleton('core/session')->setUserJustRegistered(true);
    

    然后,在任何页脚模板中,执行以下操作:

    <?php if (Mage::getSingleton('core/session')->getUserJustRegistered()): ?>
        <!-- INSERT TRACKING CODE HERE -->
        <?php Mage::getSingleton('core/session')->setUserJustRegistered(null); ?>
    <?php endif; ?>
    

    请注意,我们将会话变量重新设置为 null,这样您的跟踪代码就不会在每个页面上都触发。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-06
      • 1970-01-01
      • 2023-02-24
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      相关资源
      最近更新 更多