/** * Save customer * * @param Mage_Customer_Model_Customer $order */ protected function _saveCustomerAfterOrder($order) { if ($this->_customer) { if (!$this->_customer->getId()) { $this->_customer->save(); $order->setCustomerId($this->_customer->getId()); $this->getBillingAddress()->setCustomerId($this->_customer->getId()); $this->getShippingAddress()->setCustomerId($this->_customer->getId()); $this->_customer->sendNewAccountEmail(); } else { $saveCusstomerAddress = false; if ($this->getBillingAddress()->getSaveInAddressBook()) { $billingAddress = $this->getBillingAddress()->exportCustomerAddress(); if ($this->getBillingAddress()->getCustomerAddressId()) { $billingAddress->setId($this->getBillingAddress()->getCustomerAddressId()); } $this->_customer->addAddress($billingAddress); $saveCusstomerAddress = true; } if ($this->getShippingAddress()->getSaveInAddressBook()) { $shippingAddress = $this->getShippingAddress()->exportCustomerAddress(); if ($this->getShippingAddress()->getCustomerAddressId()) { $shippingAddress->setId($this->getShippingAddress()->getCustomerAddressId()); } $this->_customer->addAddress($shippingAddress); $saveCusstomerAddress = true; } if ($saveCusstomerAddress) { $this->_customer->save(); } } } }
public function loginByCustomer(Mage_Customer_Model_Customer $customer) { if ($customer->getConfirmation()) { $customer->setConfirmation(null); $customer->save(); } Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); }
/** * Save customer * * @deprecated after 1.4.0.0. * @param Mage_Customer_Model_Customer $order */ protected function _saveCustomerAfterOrder($order) { if ($this->_customer) { if (!$this->_customer->getId()) { $billing = $this->getBillingAddress(); $customerBilling = $billing->exportCustomerAddress(); $shipping = $this->getShippingAddress(); $customerShipping = $shipping->exportCustomerAddress(); $this->_customer->addAddress($customerBilling); if (!$shipping->getSameAsBilling()) { $this->_customer->addAddress($customerShipping); } // preliminary save to find addresses id $this->_customer->save(); // setting default addresses id $defShipping = $shipping->getSameAsBilling() ? $customerBilling->getId() : $customerShipping->getId(); $this->_customer->setDefaultBilling($customerBilling->getId())->setDefaultShipping($defShipping)->save(); $order->setCustomerId($this->_customer->getId()); $billing->setCustomerId($this->_customer->getId()); $shipping->setCustomerId($this->_customer->getId()); $this->_customer->sendNewAccountEmail('registered', '', $order->getStoreId()); } else { $saveCusstomerAddress = false; if ($this->getBillingAddress()->getSaveInAddressBook()) { $billingAddress = $this->getBillingAddress()->exportCustomerAddress(); if ($this->getBillingAddress()->getCustomerAddressId()) { $billingAddress->setId($this->getBillingAddress()->getCustomerAddressId()); } $this->_customer->addAddress($billingAddress); $saveCusstomerAddress = true; } if ($this->getShippingAddress()->getSaveInAddressBook()) { $shippingAddress = $this->getShippingAddress()->exportCustomerAddress(); if ($this->getShippingAddress()->getCustomerAddressId()) { $shippingAddress->setId($this->getShippingAddress()->getCustomerAddressId()); } $this->_customer->addAddress($shippingAddress); $saveCusstomerAddress = true; } if ($saveCusstomerAddress) { $this->_customer->save(); } } } }
/** * Set the customer account (if any) for the card. */ public function setCustomer(Mage_Customer_Model_Customer $customer, Mage_Payment_Model_Info $payment = null) { if ($customer->getEmail() != '') { $this->setCustomerEmail($customer->getEmail()); /** * Make an ID if we don't have one (and hope this doesn't break anything) */ if ($customer->getId() < 1) { $customer->save(); } $this->setCustomerId($customer->getId()); parent::setCustomer($customer); } elseif (!is_null($payment)) { $model = null; /** * If we have no email, try to find it from current scope data. */ if ($payment->getQuote() != null && $payment->getQuote()->getBillingAddress() != null && $payment->getQuote()->getBillingAddress()->getCustomerEmail() != '') { $model = $payment->getQuote(); } elseif ($payment->getOrder() != null && ($payment->getOrder()->getCustomerEmail() != '' || $payment->getOrder()->getBillingAddress() != null && $payment->getOrder()->getBillingAddress()->getCustomerEmail() != '')) { $model = $payment->getOrder(); } else { /** * This will fall back to checkout/session if onepage has no quote loaded. * Should work for all checkouts that use normal Magento processes. */ $model = Mage::getSingleton('checkout/type_onepage')->getQuote(); } if (!is_null($model)) { if ($model->getCustomerEmail() == '' && $model->getBillingAddress() instanceof Varien_Object && $model->getBillingAddress()->getEmail() != '') { $model->setCustomerEmail($model->getBillingAddress()->getEmail()); } if ($model->hasEmail()) { $this->setCustomerEmail($model->getEmail()); } elseif ($model->hasCustomerEmail()) { $this->setCustomerEmail($model->getCustomerEmail()); } $this->setCustomerId(intval($model->getCustomerId())); } } return $this; }
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_ImportExport * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $customers = array(); $customer = new Mage_Customer_Model_Customer(); $customer->setWebsiteId(1)->setEntityId(1)->setEntityTypeId(1)->setAttributeSetId(0)->setEmail('*****@*****.**')->setPassword('password')->setGroupId(1)->setStoreId(1)->setIsActive(1)->setFirstname('Firstname')->setLastname('Lastname')->setDefaultBilling(1)->setDefaultShipping(1); $customer->isObjectNew(true); $customer->save(); $customers[] = $customer; $customer = new Mage_Customer_Model_Customer(); $customer->setWebsiteId(1)->setEntityId(2)->setEntityTypeId(1)->setAttributeSetId(0)->setEmail('*****@*****.**')->setPassword('password')->setGroupId(1)->setStoreId(1)->setIsActive(1)->setFirstname('Julie')->setLastname('Worrell')->setDefaultBilling(1)->setDefaultShipping(1); $customer->isObjectNew(true); $customer->save(); $customers[] = $customer; $customer = new Mage_Customer_Model_Customer(); $customer->setWebsiteId(1)->setEntityId(3)->setEntityTypeId(1)->setAttributeSetId(0)->setEmail('*****@*****.**')->setPassword('password')->setGroupId(1)->setStoreId(1)->setIsActive(1)->setFirstname('David')->setLastname('Lamar')->setDefaultBilling(1)->setDefaultShipping(1); $customer->isObjectNew(true); $customer->save(); $customers[] = $customer; Mage::unregister('_fixture/Mage_ImportExport_Customer_Collection'); Mage::register('_fixture/Mage_ImportExport_Customer_Collection', $customers);
/** * Set customers basic data like name, gender etc. * * @param Mage_Customer_Model_Customer $magentoCustomer * @param ShopgateCustomer $shopgateCustomer * * @return Mage_Customer_Model_Customer $magentoCustomer */ protected function _registerSetBasicData($magentoCustomer, $shopgateCustomer) { $magentoCustomer->setConfirmation(null); $magentoCustomer->setFirstname($shopgateCustomer->getFirstName()); $magentoCustomer->setLastname($shopgateCustomer->getLastName()); $magentoCustomer->setGender($this->getMagentoCustomerGender($shopgateCustomer->getGender())); $magentoCustomer->setDob($shopgateCustomer->getBirthday()); $magentoCustomer->setForceConfirmed(true); $magentoCustomer->save(); $magentoCustomer->sendNewAccountEmail('registered', '', $magentoCustomer->getStore()->getId()); return $magentoCustomer; }