Magento:调用Customer Module的AccountController的createPost方法,尝试两次保存客户

时间:2013-09-27 06:09:59

标签: magento

在Magento 1.7社区版中,我已经覆盖了客户模块的AccountController。我修改了createPost方法,以便仅保存客户名称,电子邮件和密码,并返回JSON输出,以便我使用ajax调用它。

为了测试控制器是否正常工作,我直接请求方法,即:

www.mysite.com.au/customer/account/createpost/?firstname=john&lastname=smithemail=john.smith@mydomain.com&password=xxxxxx&confirmation=xxxxxx

我遇到的问题是调用$customer->save(),抛出异常 (Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS),消息为“客户电子邮件已存在”,可追溯到app/code/core/Mage/Customer/Model/Resource/Customer.php。尽管例外,仍插入客户记录。

所以Magento试图两次拯救顾客。如果我在Mage_Customer_Model_Resource_Customer:_beforeSave(Varien_Object $customer)方法的顶部退出,则会添加两个客户记录。

非常感谢任何想法。

编辑:我意识到这是在我的Windows 7 PC上运行的PHP的问题(我安装了BitNami WAMP堆栈)。我将代码复制到linux框中,并且没有发生错误。

1 个答案:

答案 0 :(得分:1)

您可能会使用新parent::createPostAction();方法拨打createPostAction(),以便第二次为客户节省时间。