删除magento中的客户地址 [英] Deleting customer addresses in magento

查看:90
本文介绍了删除magento中的客户地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式删除客户地址,但是我没有找到执行此操作的功能.

I need to delete customer addresses programmatically, but I didn't find a function to do that.

 $recordedAddresses = array();
    foreach ($customer->getAddresses() as $address)
     {
        $recordedAddresses = $address->toArray();
     }

我已经按照上面显示的那样收集了地址的集合,我只是想通过id删除它们. 奇怪的是,我没有找到示例,而是使用API​​. 有人可以帮我吗?

I already took the addresses' collection as showed above, I just wanna delete them by id. Curiously I didn't find examples but using API. Could someone gimme a hand with that?

推荐答案

看看Mage_Customer_AddressController控制器类和deleteAction()方法.基本上,您所需要做的就是通过其ID加载地址:

Have a look at the Mage_Customer_AddressController controller class and deleteAction() method. Essentially all you need to is load the address by it's id:

$address = Mage::getModel('customer/address')->load($addressId);

然后将其删除:

$address->delete();

delete()是可以在所有模型上运行的标准方法(请参见Mage_Core_Model_Abstract),还可以设置_isDeleted标志并调用save(),这将得到相同的结果.

delete() is a standard method you can run against all models (see Mage_Core_Model_Abstract), you can also set the _isDeleted flag and call save() which will have the same result.

这篇关于删除magento中的客户地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆