当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Customer_Model_Address类代码示例

本文整理汇总了PHP中Mage_Customer_Model_Address的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address类的具体用法?PHP Mage_Customer_Model_Address怎么用?PHP Mage_Customer_Model_Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mage_Customer_Model_Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addressIsValid

 /**
  * @param Mage_Customer_Model_Address $address
  * @return bool
  */
 public function addressIsValid($address)
 {
     $isValid = true;
     foreach ($this->_requiredFields as $field => $validator) {
         if (!Zend_Validate::is($address->getData($field), $validator)) {
             $isValid = false;
         }
     }
     return $isValid;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:14,代码来源:Data.php

示例2: _canProcessAddress

 /**
  * Check whether specified address should be processed in after_save event handler
  *
  * @param Mage_Customer_Model_Address $address
  * @return bool
  */
 protected function _canProcessAddress($address)
 {
     if ($address->getForceProcess()) {
         return true;
     }
     if (Mage::registry(self::VIV_CURRENTLY_SAVED_ADDRESS) != $address->getId()) {
         return false;
     }
     $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType();
     if ($configAddressType == Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING) {
         return $this->_isDefaultShipping($address);
     }
     return $this->_isDefaultBilling($address);
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:20,代码来源:Observer.php

示例3: prepareAddressData

 /**
  * Collect address data to xml node
  * Remove objects from data array and escape data values
  *
  * @param Mage_Customer_Model_Address $address
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  * @return array
  */
 public function prepareAddressData(Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     if (!$address) {
         return array();
     }
     $attributes = Mage::helper('Mage_Customer_Helper_Address')->getAttributes();
     $data = array('entity_id' => $address->getId());
     foreach ($attributes as $attribute) {
         /* @var $attribute Mage_Customer_Model_Attribute */
         if (!$attribute->getIsVisible()) {
             continue;
         }
         if ($attribute->getAttributeCode() == 'country_id') {
             $data['country'] = $address->getCountryModel()->getName();
             $data['country_id'] = $address->getCountryId();
         } else {
             if ($attribute->getAttributeCode() == 'region') {
                 $data['region'] = $address->getRegion();
             } else {
                 $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                 $value = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE);
                 if ($attribute->getFrontendInput() == 'multiline') {
                     $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $k => $v) {
                         $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1);
                         $data[$key] = $v;
                     }
                 }
                 $data[$attribute->getAttributeCode()] = $value;
             }
         }
     }
     foreach ($data as $key => $value) {
         if (empty($value)) {
             continue;
         }
         $item->addChild($key, $item->escapeXml($value));
     }
 }
开发者ID:nemphys,项目名称:magento2,代码行数:48,代码来源:List.php

示例4: isValidDataForChangeAssociationWithCountry

 /**
  * Validate data for change association with the country
  *
  * @param Mage_Customer_Model_Address $address
  * @param array $data
  * @return bool
  */
 public function isValidDataForChangeAssociationWithCountry(Mage_Customer_Model_Address $address, array $data)
 {
     if (!isset($data['country_id']) && !isset($data['region'])) {
         return true;
     }
     // If country is in data - it has been already validated. If no - load current country.
     if (isset($data['country_id'])) {
         $country = Mage::getModel('directory/country')->loadByCode($data['country_id']);
     } else {
         $country = $address->getCountryModel();
     }
     return $this->_checkRegion($data, $country);
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:20,代码来源:Validator.php

示例5: convertAddress

 /**
  * Takes a magento address object and generates an array 
  * containing data for gateway request
  *
  * @param Mage_Customer_Model_Address $address
  *
  * @return array
  */
 public function convertAddress($address)
 {
     if ($this->getConfig()->isConsumerCheck()) {
         switch ($address->getCountryId()) {
             case 'AT':
                 $staat = '040';
                 break;
             case 'CH':
                 $staat = '756';
                 break;
             case 'DE':
                 $staat = '280';
                 break;
             default:
                 $staat = '276';
                 break;
         }
     } else {
         $staat = 'DE' == $address->getCountryId() ? '280' : '276';
     }
     $addressData = array($this->_getFirstNameFieldName() => utf8_decode($this->_getFirstNameValue($address)), $this->_getLastNameFieldName() => utf8_decode($this->_getLastNameValue($address)), 'STRASSE' => utf8_decode($this->getStreet(implode(' ', $address->getStreet()))), 'HAUS_NR' => utf8_decode($this->getStreetNumber(implode(' ', $address->getStreet()))), 'ORT' => utf8_decode($address->getCity()), 'PLZ' => utf8_decode($address->getPostcode()), 'STAAT' => $staat);
     return $addressData;
 }
开发者ID:kirchbergerknorr,项目名称:netresearch_buergel,代码行数:31,代码来源:Request.php

示例6: getAddressAsString

 /**
  * Return customer address formated as one-line string
  *
  * @param Mage_Customer_Model_Address $address
  * @return string
  */
 public function getAddressAsString($address)
 {
     return $this->htmlEscape($address->format('oneline'));
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:10,代码来源:Address.php

示例7: _createPhoneNumber

 /**
  * @param Mage_Customer_Model_Address $address
  * @return array|null
  */
 protected function _createPhoneNumber(Mage_Customer_Model_Address $address)
 {
     $primaryPhone = $address->getTelephone();
     $data = array('number' => $primaryPhone, 'type' => 'UNKNOWN');
     return $data;
 }
开发者ID:ridhoq,项目名称:mxpi-twitter,代码行数:10,代码来源:Guest.php

示例8: _getFilterRegion

 /**
  * Get region filter
  *
  * @param Mage_Customer_Model_Address $address
  * @param int                         $storeId
  * @return string|bool
  */
 protected function _getFilterRegion($address, $storeId)
 {
     $filter = false;
     $regionFilters = explode(',', Mage::getStoreConfig('tax/avatax/region_filter_list', $storeId));
     $entityId = $address->getRegionId() ?: $address->getCountryId();
     if (!in_array($entityId, $regionFilters)) {
         $filter = 'region';
     }
     return $filter;
 }
开发者ID:shabirm,项目名称:avatax,代码行数:17,代码来源:Data.php

示例9: _toBraintreeAddress

 /**
  * Convert magento address to array for braintree
  * 
  * @param Mage_Customer_Model_Address $address
  * @return array
  */
 protected function _toBraintreeAddress($address)
 {
     if ($address) {
         return array('firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'company' => $address->getCompany(), 'streetAddress' => $address->getStreet(1), 'extendedAddress' => $address->getStreet(2), 'locality' => $address->getCity(), 'region' => $address->getRegion(), 'postalCode' => $address->getPostcode(), 'countryCodeAlpha2' => $address->getCountry());
     } else {
         return array();
     }
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:14,代码来源:Paymentmethod.php

示例10: _anonymizeOrderAddresses

 /**
  * @param Mage_Customer_Model_Address $customerAddress
  * @param array $randomData
  */
 protected function _anonymizeOrderAddresses($customerAddress, $randomData)
 {
     $orderAddresses = Mage::getModel('sales/order_address')->getCollection()->addFieldToFilter('customer_address_id', $customerAddress->getId());
     foreach ($orderAddresses as $orderAddress) {
         $this->_anonymizeOrderAddress($orderAddress, $randomData);
     }
 }
开发者ID:buro71a,项目名称:Anonymizer,代码行数:11,代码来源:Anonymizer.php

示例11: buildAddress

 /**
  * Build a Magento address model into a Braintree array
  *
  * @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address|Mage_Customer_Model_Address $address
  *
  * @return array
  */
 private function buildAddress($address)
 {
     // Build up the initial array
     $return = array('firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'streetAddress' => $address->getStreet1(), 'locality' => $address->getCity(), 'postalCode' => $address->getPostcode(), 'countryCodeAlpha2' => $address->getCountry());
     // Any extended address?
     if ($address->getStreet2()) {
         $return['extendedAddress'] = $address->getStreet2();
     }
     // Region
     if ($address->getRegion()) {
         $return['region'] = $address->getRegionCode();
     }
     // Check to see if we have a company
     if ($address->getCompany()) {
         $return['company'] = $address->getCompany();
     }
     return $return;
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:25,代码来源:Braintree.php

示例12: importAddress

 /**
  * Sets up address data to the GiftRegistry entity  object
  *
  * @param Mage_Customer_Model_Address $address
  * @return $this
  */
 public function importAddress(Mage_Customer_Model_Address $address)
 {
     $skip = array('increment_id', 'entity_type_id', 'parent_id', 'entity_id', 'attribute_set_id');
     $data = array();
     $attributes = $address->getAttributes();
     foreach ($attributes as $attribute) {
         if (!in_array($attribute->getAttributeCode(), $skip)) {
             $data[$attribute->getAttributeCode()] = $address->getData($attribute->getAttributeCode());
         }
     }
     $this->setData('shipping_address', serialize($data));
     return $this;
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:19,代码来源:Entity.php

示例13: importFromTextArray

 /**
  * Importing customer data from text array
  *
  * @param array $row
  * @return uMage_Customer_Model_Customer
  */
 public function importFromTextArray(array $row)
 {
     $this->resetErrors();
     $hlp = Mage::helper('customer');
     $line = $row['i'];
     $row = $row['row'];
     $regions = Mage::getResourceModel('directory/region_collection');
     //        $config = Mage::getSingleton('eav/config')->getEntityType('customer');
     $website = Mage::getModel('core/website')->load($row['website_code'], 'code');
     if (!$website->getId()) {
         $this->addError($hlp->__('Invalid website, skipping the record, line: %s.', $line));
     } else {
         $row['website_id'] = $website->getWebsiteId();
         $this->setWebsiteId($row['website_id']);
     }
     // Validate Email
     if (empty($row['email'])) {
         $this->addError($hlp->__('Missing email, skipping the record, line: %s.', $line));
     } else {
         $this->loadByEmail($row['email']);
     }
     if (empty($row['entity_id'])) {
         if ($this->getData('entity_id')) {
             $this->addError($hlp->__('The customer email (%s) already exists, skipping the record, line: %s.', $row['email'], $line));
         }
     } else {
         if ($row['entity_id'] != $this->getData('entity_id')) {
             $this->addError($hlp->__('The customer ID and email did not match, skipping the record, line: %s.', $line));
         } else {
             $this->unsetData();
             $this->load($row['entity_id']);
             if (isset($row['store_view'])) {
                 $storeId = Mage::app()->getStore($row['store_view'])->getId();
                 if ($storeId) {
                     $this->setStoreId($storeId);
                 }
             }
         }
     }
     if (empty($row['website_code'])) {
         $this->addError($hlp->__('Missing website, skipping the record, line: %s.', $line));
     }
     if (empty($row['group'])) {
         $row['group'] = 'General';
     }
     if (empty($row['firstname'])) {
         $this->addError($hlp->__('Missing first name, skipping the record, line: %s.', $line));
     }
     if (empty($row['lastname'])) {
         $this->addError($hlp->__('Missing last name, skipping the record, line: %s.', $line));
     }
     if (!empty($row['password_new'])) {
         $this->setPassword($row['password_new']);
         unset($row['password_new']);
         if (!empty($row['password_hash'])) {
             unset($row['password_hash']);
         }
     }
     if ($errors = $this->getErrors()) {
         $this->unsetData();
         $this->printError(join("<br />", $errors));
         return;
     }
     //        $entity = $this->getResource();
     foreach ($row as $field => $value) {
         //            $attribute = $entity->getAttribute($field);
         //            if (!$attribute) {
         //                echo $field;
         //                continue;
         //            }
         //            if ($attribute->usesSource()) {
         //                $source = $attribute->getSource();
         //                $optionId = $config->getSourceOptionId($source, $value);
         //                if (is_null($optionId)) {
         //                    $this->printError($hlp->__("Invalid attribute option specified for attribute attribute %s (%s).", $field, $value), $line);
         //                }
         //                $value = $optionId;
         //            }
         $this->setData($field, $value);
     }
     if (!$this->validateAddress($row, 'billing')) {
         $this->printError($hlp->__('Invalid billing address for (%s).', $row['email']), $line);
     } else {
         // Handling billing address
         $billingAddress = $this->getPrimaryBillingAddress();
         if (!$billingAddress instanceof Mage_Customer_Model_Address) {
             $billingAddress = new Mage_Customer_Model_Address();
         }
         $regions->addRegionNameFilter($row['billing_region'])->load();
         if ($regions) {
             foreach ($regions as $region) {
                 $regionId = $region->getId();
             }
         }
//.........这里部分代码省略.........
开发者ID:jpbender,项目名称:mage_virtual,代码行数:101,代码来源:Customer.php

示例14: _cleanPhone

 /**
  * _cleanPhone
  *
  * strip non-digit characters from phone/fax numbers
  *
  * @param  Mage_Customer_Model_Address $address
  * @param  string                      $type    # (i.e., 'fax' or 'telephone')
  * @param  string                      $pattern # regex pattern to use
  * @return string
  */
 protected function _cleanPhone(Mage_Customer_Model_Address $address, $type = 'telephone', $pattern = "/[^\\d]/")
 {
     $number = $address->getData($type);
     $cleanNum = preg_replace($pattern, "", $number);
     return $cleanNum;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:16,代码来源:Observer.php

示例15: withAddress

 /**
  * @param \Mage_Customer_Model_Address $address
  * @return $this
  */
 public function withAddress($address)
 {
     $this->model->getBillingAddress()->addData($address->getData());
     $this->model->getShippingAddress()->addData($address->getData())->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod($this->attributes['shipping_method'])->setPaymentMethod($this->attributes['payment_method']);
     return $this;
 }
开发者ID:jonathanselander,项目名称:Manager,代码行数:10,代码来源:Quote.php


注:本文中的Mage_Customer_Model_Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。