/** * Adds the customer test data. * * @param array $testdata Associative list of key/list pairs * @param MShop_Common_Manager_Interface $customerManager Customer manager * @param MShop_Common_Item_Address_Interface $address Customer address item * @throws MW_Setup_Exception If a required ID is not available */ protected function _addCustomerData(array $testdata, MShop_Common_Manager_Interface $customerManager, MShop_Common_Item_Address_Interface $address) { $parentIds = array(); $customer = $customerManager->createItem(); foreach ($testdata['customer'] as $key => $dataset) { $address->setCompany($dataset['company']); $address->setVatID(isset($dataset['vatid']) ? $dataset['vatid'] : ''); $address->setSalutation($dataset['salutation']); $address->setTitle($dataset['title']); $address->setFirstname($dataset['firstname']); $address->setLastname($dataset['lastname']); $address->setAddress1($dataset['address1']); $address->setAddress2($dataset['address2']); $address->setAddress3($dataset['address3']); $address->setPostal($dataset['postal']); $address->setCity($dataset['city']); $address->setState($dataset['state']); $address->setCountryId($dataset['countryid']); $address->setTelephone($dataset['telephone']); $address->setEmail($dataset['email']); $address->setTelefax($dataset['telefax']); $address->setWebsite($dataset['website']); $address->setLanguageId($dataset['langid']); $customer->setId(null); $customer->setLabel($dataset['label']); $customer->setCode($dataset['code']); $customer->setStatus($dataset['status']); $customer->setPaymentAddress($address); $customerManager->saveItem($customer); $parentIds[$key] = $customer->getId(); } return $parentIds; }
/** * Sets the billingaddress of the customer item. * * @param MShop_Common_Item_Address_Interface $address Billingaddress of the customer item */ public function setPaymentAddress(MShop_Common_Item_Address_Interface $address) { if ($address === $this->_billingaddress && $address->isModified() === false) { return; } $this->_billingaddress = $address; $this->setModified(); }
/** * Sends the notification e-mail for the given customer address and products * * @param MShop_Context_Item_Interface $context Context item object * @param MShop_Common_Item_Address_Interface $address Payment address of the customer * @param array $products List of products a notification should be sent for */ protected function _sendMail(MShop_Context_Item_Interface $context, MShop_Common_Item_Address_Interface $address, array $products) { $view = $context->getView(); $view->extProducts = $products; $view->extAddressItem = $address; $helper = new MW_View_Helper_Translate_Default($view, $context->getI18n($address->getLanguageId())); $view->addHelper('translate', $helper); $mailer = $context->getMail(); $message = $mailer->createMessage(); $helper = new MW_View_Helper_Mail_Default($view, $message); $view->addHelper('mail', $helper); $client = $this->_getClient($context); $client->setView($view); $client->getHeader(); $client->getBody(); $mailer->send($message); }
/** * Adds the customer and address data to the given customer item * * @param MShop_Customer_Item_Interface $customer Customer object * @param MShop_Common_Item_Address_Interface $address Billing address object * @return MShop_Customer_Item_Interface Customer object filled with data */ protected function _addCustomerData(MShop_Customer_Item_Interface $customer, MShop_Common_Item_Address_Interface $address) { $password = substr(md5(microtime(true) . rand()), -8); $label = $address->getLastname(); if (($part = $address->getFirstname()) !== '') { $label = $part . ' ' . $label; } if (($part = $address->getCompany()) !== '') { $label .= ' (' . $part . ')'; } $customer->setPaymentAddress($address); $customer->setCode($address->getEmail()); $customer->setPassword($password); $customer->setLabel($label); $customer->setStatus(1); return $customer; }
/** * Copys all data from a given address. * * @param MShop_Common_Item_Address_Interface $address New address */ public function copyFrom(MShop_Common_Item_Address_Interface $address) { $this->setAddressId($address->getId()); $this->setCompany($address->getCompany()); $this->setVatID($address->getVatID()); $this->setSalutation($address->getSalutation()); $this->setTitle($address->getTitle()); $this->setFirstname($address->getFirstname()); $this->setLastname($address->getLastname()); $this->setAddress1($address->getAddress1()); $this->setAddress2($address->getAddress2()); $this->setAddress3($address->getAddress3()); $this->setPostal($address->getPostal()); $this->setCity($address->getCity()); $this->setState($address->getState()); $this->setCountryId($address->getCountryId()); $this->setTelephone($address->getTelephone()); $this->setEmail($address->getEmail()); $this->setTelefax($address->getTelefax()); $this->setWebsite($address->getWebsite()); $this->setLanguageId($address->getLanguageId()); $this->setFlag($address->getFlag()); $this->setModified(); }