Definition at line 32 of file Customer.php.
_beforeDelete | ( | ) | [protected] |
Processing object before delete data
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 957 of file Customer.php.
00958 { 00959 $this->_protectFromNonAdmin(); 00960 return parent::_beforeDelete(); 00961 }
_beforeSave | ( | ) | [protected] |
Processing object before save data
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 130 of file Customer.php.
00131 { 00132 parent::_beforeSave(); 00133 00134 $storeId = $this->getStoreId(); 00135 if (is_null($storeId)) { 00136 $this->setStoreId(Mage::app()->getStore()->getId()); 00137 } 00138 00139 $this->getGroupId(); 00140 return $this; 00141 }
_construct | ( | ) |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 72 of file Customer.php.
00073 { 00074 $this->_init('customer/customer'); 00075 }
addAddress | ( | Mage_Customer_Model_Address $ | address | ) |
Add address to address collection
Mage_Customer_Model_Address | $address |
Definition at line 183 of file Customer.php.
00184 { 00185 $this->getAddresses(); 00186 $this->_addresses[] = $address; 00187 return $this; 00188 }
addError | ( | $ | error | ) |
authenticate | ( | $ | login, | |
$ | password | |||
) |
Authenticate customer
string | $login | |
string | $password |
Exception |
Definition at line 96 of file Customer.php.
00097 { 00098 $this->loadByEmail($login); 00099 if ($this->getConfirmation() && $this->isConfirmationRequired()) { 00100 throw new Exception(Mage::helper('customer')->__('This account is not confirmed.'), self::EXCEPTION_EMAIL_NOT_CONFIRMED); 00101 } 00102 if (!$this->validatePassword($password)) { 00103 throw new Exception(Mage::helper('customer')->__('Invalid login or password.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD); 00104 } 00105 Mage::dispatchEvent('customer_customer_authenticated', array( 00106 'model' => $this, 00107 'password' => $password, 00108 )); 00109 return true; 00110 }
canSkipConfirmation | ( | ) |
Check whether confirmation may be skipped when registering using certain email address
Definition at line 1039 of file Customer.php.
01040 { 01041 return $this->getId() && $this->hasSkipConfirmationIfEmail() 01042 && strtolower($this->getSkipConfirmationIfEmail()) === strtolower($this->getEmail()); 01043 }
changePassword | ( | $ | newPassword | ) |
Change customer password
string | $newPassword |
Definition at line 149 of file Customer.php.
00150 { 00151 $this->_getResource()->changePassword($this, $newPassword); 00152 return $this; 00153 }
cleanAllAddresses | ( | ) |
decryptPassword | ( | $ | password | ) |
Decrypt password
string | $password |
Definition at line 324 of file Customer.php.
00325 { 00326 return Mage::helper('core')->decrypt($password); 00327 }
encryptPassword | ( | $ | password | ) |
Encrypt password
string | $password |
Definition at line 313 of file Customer.php.
00314 { 00315 return Mage::helper('core')->encrypt($password); 00316 }
generatePassword | ( | $ | length = 6 |
) |
Retrieve random password
int | $length |
Definition at line 287 of file Customer.php.
getAdditionalAddresses | ( | ) |
Retrieve not primary addresses
Definition at line 428 of file Customer.php.
00429 { 00430 $addresses = array(); 00431 $primatyIds = $this->getPrimaryAddressIds(); 00432 foreach ($this->getAddresses() as $address) { 00433 if (!in_array($address->getId(), $primatyIds)) { 00434 $addresses[] = $address; 00435 } 00436 } 00437 return $addresses; 00438 }
getAddressById | ( | $ | addressId | ) |
Retrieve customer address by address id
int | $addressId |
Definition at line 196 of file Customer.php.
00197 { 00198 return Mage::getModel('customer/address') 00199 ->load($addressId); 00200 }
getAddressCollection | ( | ) |
Retrieve not loaded address collection
Definition at line 207 of file Customer.php.
00208 { 00209 return Mage::getResourceModel('customer/address_collection'); 00210 }
getAddresses | ( | ) |
Retrieve customer address array
Definition at line 217 of file Customer.php.
00218 { 00219 if (is_null($this->_addresses)) { 00220 $this->_addresses = array(); 00221 $collection = $this->getAddressCollection() 00222 ->setCustomerFilter($this) 00223 ->addAttributeToSelect('*') 00224 ->load(); 00225 foreach ($collection as $address) { 00226 $this->_addresses[] = $address; 00227 } 00228 } 00229 00230 return $this->_addresses; 00231 }
getAttribute | ( | $ | attributeCode | ) |
Definition at line 248 of file Customer.php.
00249 { 00250 $this->getAttributes(); 00251 if (isset($this->_attributes[$attributeCode])) { 00252 return $this->_attributes[$attributeCode]; 00253 } 00254 return null; 00255 }
getAttributes | ( | ) |
Retrieve all customer attributes
Definition at line 238 of file Customer.php.
00239 { 00240 if (null === $this->_attributes) { 00241 $this->_attributes = $this->_getResource() 00242 ->loadAllAttributes($this) 00243 ->getSortedAttributes(); 00244 } 00245 return $this->_attributes; 00246 }
getCreatedAtTimestamp | ( | ) |
Get customer created at date timestamp
Definition at line 968 of file Customer.php.
00969 { 00970 if ($date = $this->getCreatedAt()) { 00971 return $this->_getResource()->mktime($date); 00972 } 00973 return null; 00974 }
getDefaultBillingAddress | ( | ) |
Definition at line 359 of file Customer.php.
00360 { 00361 return $this->getPrimaryBillingAddress(); 00362 }
getDefaultShippingAddress | ( | ) |
Definition at line 374 of file Customer.php.
00375 { 00376 return $this->getPrimaryShippingAddress(); 00377 }
getErrors | ( | ) |
getGroupId | ( | ) |
Retrieve customer group identifier
Definition at line 548 of file Customer.php.
00549 { 00550 if (!$this->getData('group_id')) { 00551 $storeId = $this->getStoreId() ? $this->getStoreId() : Mage::app()->getStore()->getId(); 00552 $this->setData('group_id', Mage::getStoreConfig(Mage_Customer_Model_Group::XML_PATH_DEFAULT_ID, $storeId)); 00553 } 00554 return $this->getData('group_id'); 00555 }
getName | ( | ) |
Get full customer name
Definition at line 160 of file Customer.php.
00161 { 00162 $name = ''; 00163 if ($this->getPrefix()) { 00164 $name .= $this->getPrefix() . ' '; 00165 } 00166 $name .= $this->getFirstname(); 00167 if ($this->getMiddlename()) { 00168 $name .= ' ' . $this->getMiddlename(); 00169 } 00170 $name .= ' ' . $this->getLastname(); 00171 if ($this->getSuffix()) { 00172 $name .= ' ' . $this->getSuffix(); 00173 } 00174 return $name; 00175 }
getPrimaryAddress | ( | $ | attributeCode | ) |
Retrieve primary address by type(attribute)
string | $attributeCode |
Definition at line 335 of file Customer.php.
00336 { 00337 $addressId = $this->getData($attributeCode); 00338 $primaryAddress = false; 00339 if ($addressId) { 00340 foreach ($this->getAddresses() as $address) { 00341 if ($addressId == $address->getId()) { 00342 return $address; 00343 } 00344 } 00345 } 00346 return $primaryAddress; 00347 }
getPrimaryAddresses | ( | ) |
Retrieve all customer primary addresses
Definition at line 401 of file Customer.php.
00402 { 00403 $addresses = array(); 00404 $primaryBilling = $this->getPrimaryBillingAddress(); 00405 if ($primaryBilling) { 00406 $addresses[] = $primaryBilling; 00407 $primaryBilling->setIsPrimaryBilling(true); 00408 } 00409 00410 $primaryShipping = $this->getPrimaryShippingAddress(); 00411 if ($primaryShipping) { 00412 if ($primaryBilling->getId() == $primaryShipping->getId()) { 00413 $primaryBilling->setIsPrimaryShipping(true); 00414 } 00415 else { 00416 $primaryShipping->setIsPrimaryShipping(true); 00417 $addresses[] = $primaryShipping; 00418 } 00419 } 00420 return $addresses; 00421 }
getPrimaryAddressIds | ( | ) |
Retrieve ids of primary addresses
Definition at line 384 of file Customer.php.
00385 { 00386 $ids = array(); 00387 if ($this->getDefaultBilling()) { 00388 $ids[] = $this->getDefaultBilling(); 00389 } 00390 if ($this->getDefaultShipping()) { 00391 $ids[] = $this->getDefaultShipping(); 00392 } 00393 return $ids; 00394 }
getPrimaryBillingAddress | ( | ) |
Retrieve customer primary billing address
Definition at line 354 of file Customer.php.
00355 { 00356 return $this->getPrimaryAddress('default_billing'); 00357 }
getPrimaryShippingAddress | ( | ) |
Retrieve primary customer shipping address
Definition at line 369 of file Customer.php.
00370 { 00371 return $this->getPrimaryAddress('default_shipping'); 00372 }
getRandomConfirmationKey | ( | ) |
getSharedStoreIds | ( | ) |
Retrieve shared store ids
Definition at line 603 of file Customer.php.
00604 { 00605 $ids = $this->_getData('shared_store_ids'); 00606 if (is_null($ids)) { 00607 $ids = array(); 00608 if ((bool)$this->getSharingConfig()->isWebsiteScope()) { 00609 $ids = $this->getStore()->getWebsite()->getStoreIds(); 00610 } 00611 else { 00612 foreach (Mage::app()->getStores() as $store) { 00613 $ids[] = $store->getId(); 00614 } 00615 } 00616 $this->setData('shared_store_ids', $ids); 00617 } 00618 return $ids; 00619 }
getSharedWebsiteIds | ( | ) |
Retrive shared website ids
Definition at line 626 of file Customer.php.
00627 { 00628 $ids = $this->_getData('shared_website_ids'); 00629 if (is_null($ids)) { 00630 $ids = array(); 00631 if ((bool)$this->getSharingConfig()->isWebsiteScope()) { 00632 $ids[] = $this->getWebsiteId(); 00633 } 00634 else { 00635 foreach (Mage::app()->getWebsites() as $website) { 00636 $ids[] = $website->getId(); 00637 } 00638 } 00639 $this->setData('shared_website_ids', $ids); 00640 } 00641 return $ids; 00642 }
getSharingConfig | ( | ) |
Retrieve customer sharing configuration model
Definition at line 82 of file Customer.php.
00083 { 00084 return Mage::getSingleton('customer/config_share'); 00085 00086 }
getStore | ( | ) |
Retrieve store where customer was created
Definition at line 593 of file Customer.php.
00594 { 00595 return Mage::app()->getStore($this->getStoreId()); 00596 }
getTaxClassId | ( | ) |
Retrieve customer tax class identifier
Definition at line 562 of file Customer.php.
00563 { 00564 if (!$this->getData('tax_class_id')) { 00565 $this->setTaxClassId(Mage::getModel('customer/group')->getTaxClassId($this->getGroupId())); 00566 } 00567 return $this->getData('tax_class_id'); 00568 }
hashPassword | ( | $ | password, | |
$ | salt = null | |||
) |
Hach customer password
string | $password |
Definition at line 276 of file Customer.php.
00277 { 00278 return Mage::helper('core')->getHash($password, !is_null($salt) ? $salt : 2); 00279 }
importFromTextArray | ( | array $ | row | ) |
Importing customer data from text array
array | $row |
Definition at line 710 of file Customer.php.
00711 { 00712 $this->resetErrors(); 00713 $hlp = Mage::helper('customer'); 00714 $line = $row['i']; 00715 $row = $row['row']; 00716 00717 $regions = Mage::getResourceModel('directory/region_collection'); 00718 // $config = Mage::getSingleton('eav/config')->getEntityType('customer'); 00719 00720 $website = Mage::getModel('core/website')->load($row['website_code'], 'code'); 00721 00722 if (!$website->getId()) { 00723 $this->addError($hlp->__('Invalid website, skipping the record, line: %s', $line)); 00724 00725 } else { 00726 $row['website_id'] = $website->getWebsiteId(); 00727 $this->setWebsiteId($row['website_id']); 00728 } 00729 00730 // Validate Email 00731 if (empty($row['email'])) { 00732 $this->addError($hlp->__('Missing email, skipping the record, line: %s', $line)); 00733 } else { 00734 $this->loadByEmail($row['email']); 00735 } 00736 00737 if (empty($row['entity_id'])) { 00738 if ($this->getData('entity_id')) { 00739 $this->addError($hlp->__('Customer email (%s) already exists, skipping the record , line: %s', $row['email'], $line)); 00740 } 00741 } else { 00742 if ($row['entity_id'] != $this->getData('entity_id')) { 00743 $this->addError($hlp->__('CustomerID and email didn\'t match, skipping the record , line: %s', $line)); 00744 } else { 00745 $this->unsetData(); 00746 $this->load($row['entity_id']); 00747 if (isset($row['store_view'])) { 00748 $storeId = Mage::app()->getStore($row['store_view'])->getId(); 00749 if ($storeId) $this->setStoreId($storeId); 00750 } 00751 } 00752 } 00753 00754 if (empty($row['website_code'])) { 00755 $this->addError($hlp->__('Missing website, skipping the record, line: %s', $line)); 00756 } 00757 00758 if (empty($row['group'])) { 00759 $row['group'] = 'General'; 00760 } 00761 00762 if (empty($row['firstname'])) { 00763 $this->addError($hlp->__('Missing firstname, skipping the record, line: %s', $line)); 00764 } 00765 if (empty($row['lastname'])) { 00766 $this->addError($hlp->__('Missing lastname, skipping the record, line: %s', $line)); 00767 } 00768 00769 if (!empty($row['password_new'])) { 00770 $this->setPassword($row['password_new']); 00771 unset($row['password_new']); 00772 if (!empty($row['password_hash'])) unset($row['password_hash']); 00773 } 00774 00775 if ($errors = $this->getErrors()) { 00776 $this->unsetData(); 00777 $this->printError(join("<br />",$errors)); 00778 return; 00779 } 00780 // $entity = $this->getResource(); 00781 foreach ($row as $field=>$value) { 00782 00783 // $attribute = $entity->getAttribute($field); 00784 // if (!$attribute) { 00785 // echo $field; 00786 // continue; 00787 // } 00788 // if ($attribute->usesSource()) { 00789 // $source = $attribute->getSource(); 00790 // $optionId = $config->getSourceOptionId($source, $value); 00791 // if (is_null($optionId)) { 00792 // $this->printError($hlp->__("Invalid attribute option specified for attribute attribute %s (%s)", $field, $value), $line); 00793 // } 00794 // $value = $optionId; 00795 // } 00796 00797 $this->setData($field, $value); 00798 } 00799 00800 if (!$this->validateAddress($row, 'billing')) { 00801 $this->printError($hlp->__('Invalid billing address for (%s)', $row['email']), $line); 00802 } else { 00803 // Handling billing address 00804 $billingAddress = $this->getPrimaryBillingAddress(); 00805 if (!$billingAddress instanceof Mage_Customer_Model_Address) { 00806 $billingAddress = new Mage_Customer_Model_Address(); 00807 } 00808 00809 $regions->addRegionNameFilter($row['billing_region'])->load(); 00810 if ($regions) foreach($regions as $region) { 00811 $regionId = $region->getId(); 00812 } 00813 00814 $billingAddress->setFirstname($row['firstname']); 00815 $billingAddress->setLastname($row['lastname']); 00816 $billingAddress->setCity($row['billing_city']); 00817 $billingAddress->setRegion($row['billing_region']); 00818 if (isset($regionId)) $billingAddress->setRegionId($regionId); 00819 $billingAddress->setCountryId($row['billing_country']); 00820 $billingAddress->setPostcode($row['billing_postcode']); 00821 if (isset($row['billing_street2'])) { 00822 $billingAddress->setStreet(array($row['billing_street1'],$row['billing_street2'])); 00823 } else { 00824 $billingAddress->setStreet(array($row['billing_street1'])); 00825 } 00826 if (isset($row['billing_telephone'])) { 00827 $billingAddress->setTelephone($row['billing_telephone']); 00828 } 00829 00830 if (!$billingAddress->getId()) { 00831 $billingAddress->setIsDefaultBilling(true); 00832 if ($this->getDefaultBilling()) { 00833 $this->setData('default_billing', ''); 00834 } 00835 $this->addAddress($billingAddress); 00836 } // End handling billing address 00837 } 00838 00839 if (!$this->validateAddress($row, 'shipping')) { 00840 $this->printError($hlp->__('Invalid shipping address for (%s)', $row['email']), $line); 00841 } else { 00842 // Handling shipping address 00843 $shippingAddress = $this->getPrimaryShippingAddress(); 00844 if (!$shippingAddress instanceof Mage_Customer_Model_Address) { 00845 $shippingAddress = new Mage_Customer_Model_Address(); 00846 } 00847 00848 $regions->addRegionNameFilter($row['shipping_region'])->load(); 00849 00850 if ($regions) foreach($regions as $region) { 00851 $regionId = $region->getId(); 00852 } 00853 00854 $shippingAddress->setFirstname($row['firstname']); 00855 $shippingAddress->setLastname($row['lastname']); 00856 $shippingAddress->setCity($row['shipping_city']); 00857 $shippingAddress->setRegion($row['shipping_region']); 00858 if (isset($regionId)) $shippingAddress->setRegionId($regionId); 00859 $shippingAddress->setCountryId($row['shipping_country']); 00860 $shippingAddress->setPostcode($row['shipping_postcode']); 00861 if (isset($row['shipping_street2'])) { 00862 $shippingAddress->setStreet(array($row['shipping_street1'], $row['shipping_street2'])); 00863 } else { 00864 $shippingAddress->setStreet(array($row['shipping_street1'])); 00865 } 00866 if (!empty($row['shipping_telephone'])) { 00867 $shippingAddress->setTelephone($row['shipping_telephone']); 00868 } 00869 00870 if (!$shippingAddress->getId()) { 00871 $shippingAddress->setIsDefaultShipping(true); 00872 $this->addAddress($shippingAddress); 00873 } 00874 // End handling shipping address 00875 } 00876 if (!empty($row['is_subscribed'])) { 00877 $this->setIsSubscribed(strtolower($row['is_subscribed'])==self::SUBSCRIBED_YES ? 1 : 0); 00878 } 00879 unset($row); 00880 return $this; 00881 }
isAddressPrimary | ( | Mage_Customer_Model_Address $ | address | ) |
Definition at line 440 of file Customer.php.
00441 { 00442 if (!$address->getId()) { 00443 return false; 00444 } 00445 return ($address->getId() == $this->getDefaultBilling()) || ($address->getId() == $this->getDefaultShipping()); 00446 }
isConfirmationRequired | ( | ) |
Check if accounts confirmation is required in config
Definition at line 494 of file Customer.php.
00495 { 00496 if ($this->canSkipConfirmation()) { 00497 return false; 00498 } 00499 if (null === self::$_isConfirmationRequired) { 00500 self::$_isConfirmationRequired = 1 == Mage::getStoreConfig(self::XML_PATH_IS_CONFIRM, ($this->getStoreId() ? $this->getStoreId() : null)); 00501 } 00502 return self::$_isConfirmationRequired; 00503 }
isDeleteable | ( | ) |
isInStore | ( | $ | store | ) |
Check store availability for customer
mixed | $store |
Definition at line 576 of file Customer.php.
00577 { 00578 if ($store instanceof Mage_Core_Model_Store) { 00579 $storeId = $store->getId(); 00580 } 00581 else { 00582 $storeId = $store; 00583 } 00584 $availableStores = $this->getSharedStoreIds(); 00585 return in_array($storeId, $availableStores); 00586 }
isReadonly | ( | ) |
loadByEmail | ( | $ | customerEmail | ) |
Load customer by email
string | $customerEmail |
Definition at line 118 of file Customer.php.
00119 { 00120 $this->_getResource()->loadByEmail($this, $customerEmail); 00121 return $this; 00122 }
printError | ( | $ | error, | |
$ | line = null | |||
) |
Definition at line 909 of file Customer.php.
00910 { 00911 if ($error == null) return false; 00912 $img = 'error_msg_icon.gif'; 00913 $liStyle = 'background-color:#FDD; '; 00914 echo '<li style="'.$liStyle.'">'; 00915 echo '<img src="'.Mage::getDesign()->getSkinUrl('images/'.$img).'" class="v-middle"/>'; 00916 echo $error; 00917 if ($line) { 00918 echo '<small>, Line: <b>'.$line.'</b></small>'; 00919 } 00920 echo "</li>"; 00921 }
reset | ( | ) |
Reset all model data
Definition at line 981 of file Customer.php.
00982 { 00983 $this->setData(array()); 00984 $this->setOrigData(); 00985 $this->_attributes = null; 00986 00987 return $this; 00988 }
resetErrors | ( | ) |
sendNewAccountEmail | ( | $ | type = 'registered' , |
|
$ | backUrl = '' | |||
) |
Send email with new account specific information
Definition at line 453 of file Customer.php.
00454 { 00455 $types = array( 00456 'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled 00457 'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled 00458 'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link 00459 ); 00460 if (!isset($types[$type])) { 00461 throw new Exception(Mage::helper('customer')->__('Wrong transactional account email type.')); 00462 } 00463 00464 $translate = Mage::getSingleton('core/translate'); 00465 /* @var $translate Mage_Core_Model_Translate */ 00466 $translate->setTranslateInline(false); 00467 00468 $storeId = $this->getStoreId(); 00469 if ($this->getWebsiteId() != '0' && $storeId == '0') { 00470 $storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds(); 00471 reset($storeIds); 00472 $storeId = current($storeIds); 00473 } 00474 00475 Mage::getModel('core/email_template') 00476 ->setDesignConfig(array('area'=>'frontend', 'store'=>$storeId)) 00477 ->sendTransactional( 00478 Mage::getStoreConfig($types[$type]), 00479 Mage::getStoreConfig(self::XML_PATH_REGISTER_EMAIL_IDENTITY), 00480 $this->getEmail(), 00481 $this->getName(), 00482 array('customer' => $this, 'back_url' => $backUrl)); 00483 00484 $translate->setTranslateInline(true); 00485 00486 return $this; 00487 }
sendPasswordReminderEmail | ( | ) |
Send email with new customer password
Definition at line 515 of file Customer.php.
00516 { 00517 $translate = Mage::getSingleton('core/translate'); 00518 /* @var $translate Mage_Core_Model_Translate */ 00519 $translate->setTranslateInline(false); 00520 00521 $storeId = $this->getStoreId(); 00522 if ($this->getWebsiteId() != '0' && $storeId == '0') { 00523 $storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds(); 00524 reset($storeIds); 00525 $storeId = current($storeIds); 00526 } 00527 00528 Mage::getModel('core/email_template') 00529 ->setDesignConfig(array('area'=>'frontend', 'store'=>$storeId)) 00530 ->sendTransactional( 00531 Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_TEMPLATE), 00532 Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_IDENTITY), 00533 $this->getEmail(), 00534 $this->getName(), 00535 array('customer'=>$this) 00536 ); 00537 00538 $translate->setTranslateInline(true); 00539 00540 return $this; 00541 }
setIsDeleteable | ( | $ | value | ) |
Set is deleteable flag
boolean | $value |
Definition at line 1006 of file Customer.php.
setIsReadonly | ( | $ | value | ) |
Set is readonly flag
boolean | $value |
Definition at line 1028 of file Customer.php.
setPassword | ( | $ | password | ) |
Set plain and hashed password
string | $password |
Definition at line 263 of file Customer.php.
00264 { 00265 $this->setData('password', $password); 00266 $this->setPasswordHash($this->hashPassword($password)); 00267 return $this; 00268 }
setStore | ( | Mage_Core_Model_Store $ | store | ) |
Enter description here...
Mage_Core_Model_Store | $store |
Definition at line 650 of file Customer.php.
unsetSubscription | ( | ) |
validate | ( | ) |
Validate customer attribute values
Definition at line 661 of file Customer.php.
00662 { 00663 $errors = array(); 00664 00665 if (!Zend_Validate::is( trim($this->getFirstname()) , 'NotEmpty')) { 00666 $errors[] = Mage::helper('customer')->__('First name can\'t be empty'); 00667 } 00668 00669 if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) { 00670 $errors[] = Mage::helper('customer')->__('Last name can\'t be empty'); 00671 } 00672 00673 if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) { 00674 $errors[] = Mage::helper('customer')->__('Invalid email address "%s"', $this->getEmail()); 00675 } 00676 00677 $password = $this->getPassword(); 00678 if (!$this->getId() && !Zend_Validate::is($password , 'NotEmpty')) { 00679 $errors[] = Mage::helper('customer')->__('Password can\'t be empty'); 00680 } 00681 if ($password && !Zend_Validate::is($password, 'StringLength', array(6))) { 00682 $errors[] = Mage::helper('customer')->__('Password minimal length must be more %s', 6); 00683 } 00684 $confirmation = $this->getConfirmation(); 00685 if ($password != $confirmation) { 00686 $errors[] = Mage::helper('customer')->__('Please make sure your passwords match.'); 00687 } 00688 00689 if (('req' === Mage::helper('customer/address')->getConfig('dob_show')) 00690 && '' == trim($this->getDob())) { 00691 $errors[] = Mage::helper('customer')->__('Date of Birth is required.'); 00692 } 00693 if (('req' === Mage::helper('customer/address')->getConfig('taxvat_show')) 00694 && '' == trim($this->getTaxvat())) { 00695 $errors[] = Mage::helper('customer')->__('TAX/VAT number is required.'); 00696 } 00697 00698 if (empty($errors)) { 00699 return true; 00700 } 00701 return $errors; 00702 }
validateAddress | ( | array $ | data, | |
$ | type = 'billing' | |||
) |
Definition at line 923 of file Customer.php.
00924 { 00925 $fields = array('city', 00926 'country', 'postcode', 00927 'telephone', 'street1'); 00928 $usca = array('US', 'CA'); 00929 $prefix = $type ? $type.'_':''; 00930 00931 if ($data) { 00932 foreach($fields as $field) { 00933 if (!isset($data[$prefix.$field])) { 00934 return false; 00935 } 00936 if ($field == 'country' 00937 && in_array(strtolower($data[$prefix.$field]), array('US', 'CA'))) { 00938 00939 if (!isset($data[$prefix.'region'])) { 00940 return false; 00941 } 00942 00943 $region = Mage::getModel('directory/region') 00944 ->loadByName($data[$prefix.'region']); 00945 if (!$region->getId()) { 00946 return false; 00947 } 00948 unset($region); 00949 } 00950 } 00951 unset($data); 00952 return true; 00953 } 00954 return false; 00955 }
validatePassword | ( | $ | password | ) |
Validate password with salted hash
string | $password |
Definition at line 298 of file Customer.php.
00299 { 00300 if (!($hash = $this->getPasswordHash())) { 00301 return false; 00302 } 00303 return Mage::helper('core')->validateHash($password, $hash); 00304 }
$_addresses = null [protected] |
Definition at line 51 of file Customer.php.
$_attributes [protected] |
Definition at line 53 of file Customer.php.
$_errors = array() [protected] |
Definition at line 52 of file Customer.php.
$_eventObject = 'customer' [protected] |
$_eventPrefix = 'customer' [protected] |
$_isDeleteable = true [protected] |
Definition at line 60 of file Customer.php.
$_isReadonly = false [protected] |
Definition at line 67 of file Customer.php.
const EXCEPTION_EMAIL_NOT_CONFIRMED = 1 |
Definition at line 43 of file Customer.php.
const EXCEPTION_INVALID_EMAIL_OR_PASSWORD = 2 |
Definition at line 44 of file Customer.php.
const SUBSCRIBED_NO = 'no' |
Definition at line 47 of file Customer.php.
const SUBSCRIBED_YES = 'yes' |
Definition at line 46 of file Customer.php.
const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template' |
Definition at line 40 of file Customer.php.
const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template' |
Definition at line 41 of file Customer.php.
const XML_PATH_DEFAULT_EMAIL_DOMAIN = 'customer/create_account/email_domain' |
Definition at line 38 of file Customer.php.
const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity' |
Definition at line 37 of file Customer.php.
const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template' |
Definition at line 36 of file Customer.php.
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm' |
Definition at line 39 of file Customer.php.
const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity' |
Definition at line 35 of file Customer.php.
const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template' |
Definition at line 34 of file Customer.php.