[英]Magento custom registration success message after redirect to dashboard
I need to extend the custom success message after the customer registration. 客户注册后,我需要扩展自定义成功消息。 Now after registration the user is redirected to the dashboard and the standard success message is shown: "Thank you for registering with...".
现在,注册后,用户将被重定向到仪表板,并显示标准成功消息:“谢谢您使用...注册”。
I need that this message changes base on the customer group attribute. 我需要根据客户组属性更改此消息。 I read on-line but didn't find a working solution... but I think I'm making it in the wrong way.
我在线阅读,但是找不到可行的解决方案...但是我认为我做错了方法。 I started from here: http://mydons.com/simple-example-using-magento-event-observer/ to make a custom observer on the customer_register_success event, so I made the module xml named Bbox_Regmess.xml in app/etc/modules:
我从这里开始: http ://mydons.com/simple-example-using-magento-event-observer/在customer_register_success事件上创建自定义观察者,因此我在app / etc /中创建了名为Bbox_Regmess.xml的模块xml。模块:
<config>
<modules>
<Bbox_Regmess>
<active>true</active>
<codePool>local</codePool>
</Bbox_Regmess>
</modules>
</config>
Than I made the app/code/local/Bbox/Regmess/etc and app/code/local/Bbox/Regmess/Model folders with inside the config.xml: 比起我在config.xml中创建app / code / local / Bbox / Regmess / etc和app / code / local / Bbox / Regmess / Model文件夹:
<config>
<modules>
<Bbox_Regmess>
<version>0.1.0</version>
</Bbox_Regmess>
</modules>
<frontend>
<events>
<customer_register_success>
<observers>
<Bbox_Regmess_Model_Observer>
<type>singleton</type>
<class>Bbox_Regmess_Model_Observer</class>
<method>Customregmess</method>
</Bbox_Regmess_Model_Observer>
</observers>
</customer_register_success>
</events>
</frontend>
</config>
And the Observer.php that is just a first try to see if I'm able to add a custom success message: 而Observer.php只是第一次尝试看看我是否能够添加自定义成功消息:
<?php
class Bbox_Regmess_Model_Observer {
public function Customregmess($observer) {
$event = $observer->getEvent(); //Fetches the current event
$customer = $event->getCustomer();
$eventmsg = "Current Event Triggered : <I>" . $event->getName() . "</I><br/> Currently Added Product : <I> " . $customer->getCustomerName()."</I>";
//Adds Custom message to shopping cart
Mage::getSingleton('customer/session')->addSuccess($eventmsg);
}
}
?>
Now if a user registers to the shop, he get the standard registration message and there is not the custom $eventmsg 现在,如果用户向商店注册,他将获得标准注册消息,并且没有自定义$ eventmsg
What I'm making wrong? 我做错了什么? There is another way to to that?
还有另一种方法吗? Thanks
谢谢
UPDATE: 更新:
looking deeper I found out the default success message is defined in the app/code/core/Mage/Customer/controllers/AccountController.php at line 390 (just after the line 334 where there is the definition of customer_register_success event I'm trying to work with). 更深入地了解,我发现默认成功消息是在app / code / core / Mage / Customer / controllers / AccountController.php中的第390行定义的(仅在第334行之后,这里我正在尝试对customer_register_success事件进行定义)使用)。
at line 390 there is the _welcomeCustomer function that is in charge of setting the success message, send confirmation email and set the success redirect url: 在第390行,_welcomeCustomer函数负责设置成功消息,发送确认电子邮件并设置成功重定向URL:
protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
{
$this->_getSession()->addSuccess(
$this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())
);
$customer->sendNewAccountEmail(
$isJustConfirmed ? 'confirmed' : 'registered',
'',
Mage::app()->getStore()->getId()
);
$successUrl = Mage::getUrl('*/*/index', array('_secure'=>true));
if ($this->_getSession()->getBeforeAuthUrl()) {
$successUrl = $this->_getSession()->getBeforeAuthUrl(true);
}
return $successUrl;
}
Is there any chance to extend this function so I can manage multiple success message base on the customer group? 有机会扩展此功能,以便我可以根据客户群管理多个成功消息吗?
I've look for some resource about it, but I didn't find anything usefull 我一直在寻找有关它的资源,但没有发现任何有用的信息
I think that you must place the events tag in the global tag 我认为您必须将事件标签放置在全局标签中
<config><global>...<events>...</events>...</global>...</config>
EDIT: 编辑:
and the observer file extends Varien_Event_Observer, at least that worked with mine 和观察者文件扩展了Varien_Event_Observer,至少与我的合作
class Bbox_Regmess_Model_Observer extends Varien_Event_Observer{}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.