Pergunta

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); 
}
Foi útil?

Solução

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();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top