문제

How can we set Country in Customer A/c Details Manually.

I am trying to execute code as following and

So Please Suggest Answer in that criteria :

 if (!$customer->getId()) {
                $customer->setEmail($email);
                $customer->setFirstname($name);
                $customer->setLastname($lastname);
                $customer->setPassword($password); 
}
도움이 되었습니까?

해결책

As @FabianBlechschmidt said - the customer entity doesn't have a country, the customer has an address, which has a country.

Depending on what address you wanted to update exactly, you could use something like this

$_customer = Mage::getModel('customer/customer')->load($customerId);

Then load the respective model,

$_addresssModel = $_customer->getDefaultBillingAddress();
$_addresssModel = $_customer->getDefaultShippingAddress();

Then set the country ID,

$_addresssModel->setCountryId('x')->save();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top