本文整理汇总了PHP中Mage_Customer_Model_Address::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address::getId方法的具体用法?PHP Mage_Customer_Model_Address::getId怎么用?PHP Mage_Customer_Model_Address::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Customer_Model_Address
的用法示例。
在下文中一共展示了Mage_Customer_Model_Address::getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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);
}
示例2: 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));
}
}
示例3: isAddressPrimary
/**
* Check if address is primary
*
* @param Mage_Customer_Model_Address $address
* @return boolean
*/
public function isAddressPrimary(Mage_Customer_Model_Address $address)
{
if (!$address->getId()) {
return false;
}
return $address->getId() == $this->getDefaultBilling() || $address->getId() == $this->getDefaultShipping();
}
示例4: parse
/**
* @deprecated not used anymore
*/
public function parse()
{
$data = $this->getData();
$entityTypeId = Mage::getSingleton('eav/config')->getEntityType('customer')->getId();
$result = array();
foreach ($data as $i => $row) {
$this->setPosition('Line: ' . ($i + 1));
try {
// validate SKU
if (empty($row['email'])) {
$this->addException(Mage::helper('customer')->__('Missing email, skipping the record'), Varien_Convert_Exception::ERROR);
continue;
}
$this->setPosition('Line: ' . ($i + 1) . ', email: ' . $row['email']);
// try to get entity_id by sku if not set
/*
if (empty($row['entity_id'])) {
$row['entity_id'] = $this->getResource()->getProductIdBySku($row['email']);
}
*/
// if attribute_set not set use default
if (empty($row['attribute_set'])) {
$row['attribute_set'] = 'Default';
}
// get attribute_set_id, if not throw error
$row['attribute_set_id'] = $this->getAttributeSetId($entityTypeId, $row['attribute_set']);
if (!$row['attribute_set_id']) {
$this->addException(Mage::helper('customer')->__("Invalid attribute set specified, skipping the record"), Varien_Convert_Exception::ERROR);
continue;
}
if (empty($row['group'])) {
$row['group'] = 'General';
}
if (empty($row['firstname'])) {
$this->addException(Mage::helper('customer')->__('Missing firstname, skipping the record'), Varien_Convert_Exception::ERROR);
continue;
}
//$this->setPosition('Line: '.($i+1).', Firstname: '.$row['firstname']);
if (empty($row['lastname'])) {
$this->addException(Mage::helper('customer')->__('Missing lastname, skipping the record'), Varien_Convert_Exception::ERROR);
continue;
}
//$this->setPosition('Line: '.($i+1).', Lastname: '.$row['lastname']);
/*
// get product type_id, if not throw error
$row['type_id'] = $this->getProductTypeId($row['type']);
if (!$row['type_id']) {
$this->addException(Mage::helper('catalog')->__("Invalid product type specified, skipping the record"), Varien_Convert_Exception::ERROR);
continue;
}
*/
// get store ids
$storeIds = $this->getStoreIds(isset($row['store']) ? $row['store'] : $this->getVar('store'));
if (!$storeIds) {
$this->addException(Mage::helper('customer')->__("Invalid store specified, skipping the record"), Varien_Convert_Exception::ERROR);
continue;
}
// import data
$rowError = false;
foreach ($storeIds as $storeId) {
$collection = $this->getCollection($storeId);
//print_r($collection);
$entity = $collection->getEntity();
$model = Mage::getModel('customer/customer');
$model->setStoreId($storeId);
if (!empty($row['entity_id'])) {
$model->load($row['entity_id']);
}
foreach ($row as $field => $value) {
$attribute = $entity->getAttribute($field);
if (!$attribute) {
continue;
#$this->addException(Mage::helper('catalog')->__("Unknown attribute: %s", $field), Varien_Convert_Exception::ERROR);
}
if ($attribute->usesSource()) {
$source = $attribute->getSource();
$optionId = $this->getSourceOptionId($source, $value);
if (is_null($optionId)) {
$rowError = true;
$this->addException(Mage::helper('customer')->__("Invalid attribute option specified for attribute %s (%s), skipping the record", $field, $value), Varien_Convert_Exception::ERROR);
continue;
}
$value = $optionId;
}
$model->setData($field, $value);
}
//foreach ($row as $field=>$value)
$billingAddress = $model->getPrimaryBillingAddress();
$customer = Mage::getModel('customer/customer')->load($model->getId());
if (!$billingAddress instanceof Mage_Customer_Model_Address) {
$billingAddress = new Mage_Customer_Model_Address();
if ($customer->getId() && $customer->getDefaultBilling()) {
$billingAddress->setId($customer->getDefaultBilling());
}
}
$regions = Mage::getResourceModel('directory/region_collection')->addRegionNameFilter($row['billing_region'])->load();
if ($regions) {
//.........这里部分代码省略.........
开发者ID:ankita-parashar,项目名称:magento,代码行数:101,代码来源:Intersec_Orderimportexport_Model_Convert_Parser_guest+orders_Exportorders.php
示例5: _isDefaultShippingAddress
/**
* Is specified address a default shipping address?
*
* @param Mage_Customer_Model_Address $address
* @return bool
*/
protected function _isDefaultShippingAddress(Mage_Customer_Model_Address $address)
{
return $address->getCustomer()->getDefaultShipping() == $address->getId();
}
示例6: importCustomerAddress
/**
* Import quote address data from customer address object
*
* @param Mage_Customer_Model_Address $address
* @return Mage_Sales_Model_Quote_Address
*/
public function importCustomerAddress(Mage_Customer_Model_Address $address)
{
$this->setCustomerAddressId($address->getId())->setCustomerId($address->getParentId())->setEmail($address->hasEmail() ? $address->getEmail() : $address->getCustomer()->getEmail())->setFirstname($address->getFirstname())->setLastname($address->getLastname())->setCompany($address->getCompany())->setStreet($address->getStreet())->setCity($address->getCity())->setRegion($address->getRegion())->setRegionId($address->getRegionId())->setPostcode($address->getPostcode())->setCountryId($address->getCountryId())->setTelephone($address->getTelephone())->setFax($address->getFax());
return $this;
}
示例7: 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();
}
}
//.........这里部分代码省略.........
示例8: _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);
}
}
示例9: testPrepareCustomerAddressForSave
/**
* @param array $addressData
* @param Mage_Customer_Model_Address|null $newAddress
* @param Mage_Customer_Model_Address|null $existingAddress
* @param array $addressCollection
* @param bool $dataChanged
* @param bool $expectedDataChange
* @dataProvider addressesDataProvider
*/
public function testPrepareCustomerAddressForSave(array $addressData, $newAddress, $existingAddress, array $addressCollection, $dataChanged, $expectedDataChange)
{
$this->_customer->setDataChanges($dataChanged);
$this->_customer->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->_customer->expects($this->once())->method('getAddressesCollection')->will($this->returnValue($addressCollection));
if ($newAddress) {
// Check that customer_id is set for new addresses
$newAddress->expects($this->once())->method('setCustomerId')->with(1);
// Check that new address is added to customer address collection
$this->_customer->expects($this->once())->method('addAddress');
// Check that new address is not deleted
$newAddress->expects($this->never())->method('setData')->with('_deleted', true);
}
// Check that address loaded from customer address collection
if ($existingAddress && $addressData) {
$this->_customer->expects($this->once())->method('getAddressItemById')->with($existingAddress->getId())->will($this->returnValue($existingAddress));
}
// Check that new data is added
$hasExistingAddress = false;
foreach ($addressData as $data) {
if (array_key_exists('entity_id', $addressData)) {
unset($data['entity_id']);
$existingAddress->expects($this->once())->method('addData')->with($data);
$hasExistingAddress = true;
} elseif ($newAddress) {
$newAddress->expects($this->once())->method('addData')->with($data);
}
}
// Check that addresses is deleted
if (in_array($existingAddress, $addressCollection) && !$hasExistingAddress) {
$existingAddress->expects($this->atLeastOnce())->method('setData')->with('_deleted', true);
}
$this->assertInstanceOf('Mage_Customer_Model_Customer', $this->_service->update(1, array(), $addressData), 'Incorrect instance returned');
$this->assertEquals($expectedDataChange, $this->_customer->hasDataChanges(), 'Customer change data status is incorrect');
}