$session = Mage::getSingleton('customer/session'); $customer_id = $session->getId(); $customer_data = Mage::getModel('customer/customer')->load($customer_id); print_r($customer_data);
通过此代码ican获取用户详细信息,我需要知道如何使用Php代码以相同的方式编辑地址,密码..等用户详细信息谢谢所有
你可以使用php magic get和set方法
假设设置密码你可以使用 $customer_data->setPassword('1234567');
$customer_data->setPassword('1234567');
$customer_data->save();
对于客户地址
$_custom_address = array ( 'firstname' => 'firstname', 'lastname' => 'lastname', 'street' => array ( '0' => 'Sample address part1', '1' => 'Sample address part2', ), 'city' => 'city', 'region_id' => '', 'region' => '', 'postcode' => '31000', 'country_id' => 'US', 'telephone' => '0038531555444', ); $customAddress = Mage::getModel('customer/address') $customAddress->setData($_custom_address) ->setCustomerId($customer->getId()) ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1'); try { $customAddress->save(); } catch (Exception $ex) { //Zend_Debug::dump($ex->getMessage()); }
欲了解更多信息http://inchoo.net/ecommerce/magento/programming-magento/programatically-create-customer-and-order-in-magento-with-full-blown-one-page-checkout-process-under-the-hood/
对于密码,您可以使用$ customer_id进行设置
$password = 'Any Things' $customer = Mage::getModel('customer/customer')->load($customer_id); $customer->setPassword($password); $customer->save();
对于编辑地址,您必须加载地址模型
例如,如果要编辑帐单地址:
$customer = Mage::getModel('customer/customer')->load($customer_id); $address = $customer->getDefaultBilling(); $address->setFirstname("Test"); $address->save();
OR:使用地址id从客户对象获取:
$address = Mage::getModel('customer/address')->load($customerAddressId); $address->setFirstname("Test"); $address->save();
您可以使用Mage_Customer_Model_Customer类的方法:
$customerSession = Mage::getSingleton('customer/session'); $customerModel = Mage::getModel('customer/customer')->load($customerSession->getId()); $customerModel->changePassword('new_password');
3 回答
你可以使用php magic get和set方法
假设设置密码你可以使用
$customer_data->setPassword('1234567');
对于客户地址
欲了解更多信息http://inchoo.net/ecommerce/magento/programming-magento/programatically-create-customer-and-order-in-magento-with-full-blown-one-page-checkout-process-under-the-hood/
对于密码,您可以使用$ customer_id进行设置
对于编辑地址,您必须加载地址模型
例如,如果要编辑帐单地址:
OR:使用地址id从客户对象获取:
您可以使用Mage_Customer_Model_Customer类的方法: