2011-02-11 26 views
2

我想在注册期间使用来自另一个系统的数据填充地址字段。在我的观察,我可以使用Magento 1.4.2 - 在注册期间设置地址字段

$customer = $observer->getCustomer(); 
$customer->setFirstname($value); 
$customer->setLastname($value); 

和信息保存在数据库中,但

$customer->setStreet($value); 
$customer->setPostcode($value); 
$customer->setTelephone($value); 

没有。我将如何设置地址字段? 谢谢!

+0

检查http://stackoverflow.com/questions/8337929/how-to-add-the-address-fields-in-the-customer-registration-form/9545070#9545070 – MTM 2014-06-13 08:29:01

回答

1

地址不存储在Mage_Customer_Model_Customer对象中。而应该这样做:

$address = Mage::getModel('customer/address'); 
$address->setStreet(...); 
... 
$customer->addAddress($address); 
+0

谢谢你的回应!我试过了你的代码,并在`$ customer-> addAddress($ address);`之前添加了`Mage :: log($ address);``。我在日志中获取我的整个地址,但它仍然没有保存到数据库中。 – bonhommie 2011-02-15 02:33:39

0

我发现了一些好的帖子: 这对我来说更容易:-) http://www.pauldonnellydesigns.com/blog/magento-display-address-fields-in-create-an-account/ 和更长的岗位: http://www.magentocommerce.com/boards/viewthread/11110/

它的工作,我检查。

我需要显示领域形成的订单地址,控制器:/结帐/ onepage在页面上用表格登录和注册(我要添加字段的个人与步长寄存器地址)

难道有人看到代码来创建这个功能?

相关问题