本文整理汇总了PHP中Mage_Customer_Model_Address::setRegionId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address::setRegionId方法的具体用法?PHP Mage_Customer_Model_Address::setRegionId怎么用?PHP Mage_Customer_Model_Address::setRegionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Customer_Model_Address
的用法示例。
在下文中一共展示了Mage_Customer_Model_Address::setRegionId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
//.........这里部分代码省略.........
#$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) {
foreach ($regions as $region) {
$regionId = $region->getId();
}
}
$billingAddress->setFirstname($row['firstname']);
$billingAddress->setLastname($row['lastname']);
$billingAddress->setCity($row['billing_city']);
$billingAddress->setRegion($row['billing_region']);
$billingAddress->setRegionId($regionId);
$billingAddress->setCountryId($row['billing_country']);
$billingAddress->setPostcode($row['billing_postcode']);
$billingAddress->setStreet(array($row['billing_street1'], $row['billing_street2']));
if (!empty($row['billing_telephone'])) {
$billingAddress->setTelephone($row['billing_telephone']);
}
if (!$model->getDefaultBilling()) {
$billingAddress->setCustomerId($model->getId());
$billingAddress->setIsDefaultBilling(true);
$billingAddress->save();
$model->setDefaultBilling($billingAddress->getId());
$model->addAddress($billingAddress);
if ($customer->getDefaultBilling()) {
$model->setDefaultBilling($customer->getDefaultBilling());
} else {
$shippingAddress->save();
$model->setDefaultShipping($billingAddress->getId());
$model->addAddress($billingAddress);
}
}
$shippingAddress = $model->getPrimaryShippingAddress();
if (!$shippingAddress instanceof Mage_Customer_Model_Address) {
$shippingAddress = new Mage_Customer_Model_Address();
if ($customer->getId() && $customer->getDefaultShipping()) {
$shippingAddress->setId($customer->getDefaultShipping());
}
}
$regions = Mage::getResourceModel('directory/region_collection')->addRegionNameFilter($row['shipping_region'])->load();
if ($regions) {
foreach ($regions as $region) {
$regionId = $region->getId();
}
开发者ID:ankita-parashar,项目名称:magento,代码行数:67,代码来源:Intersec_Orderimportexport_Model_Convert_Parser_guest+orders_Exportorders.php
示例2: importFromTextArray
//.........这里部分代码省略.........
// $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();
}
}
$billingAddress->setFirstname($row['firstname']);
$billingAddress->setLastname($row['lastname']);
$billingAddress->setCity($row['billing_city']);
$billingAddress->setRegion($row['billing_region']);
if (isset($regionId)) {
$billingAddress->setRegionId($regionId);
}
$billingAddress->setCountryId($row['billing_country']);
$billingAddress->setPostcode($row['billing_postcode']);
if (isset($row['billing_street2'])) {
$billingAddress->setStreet(array($row['billing_street1'], $row['billing_street2']));
} else {
$billingAddress->setStreet(array($row['billing_street1']));
}
if (isset($row['billing_telephone'])) {
$billingAddress->setTelephone($row['billing_telephone']);
}
if (!$billingAddress->getId()) {
$billingAddress->setIsDefaultBilling(true);
if ($this->getDefaultBilling()) {
$this->setData('default_billing', '');
}
$this->addAddress($billingAddress);
}
// End handling billing address
}
if (!$this->validateAddress($row, 'shipping')) {
$this->printError($hlp->__('Invalid shipping address for (%s).', $row['email']), $line);
} else {
// Handling shipping address
$shippingAddress = $this->getPrimaryShippingAddress();
if (!$shippingAddress instanceof Mage_Customer_Model_Address) {
$shippingAddress = new Mage_Customer_Model_Address();
}
$regions->addRegionNameFilter($row['shipping_region'])->load();
if ($regions) {
foreach ($regions as $region) {
$regionId = $region->getId();
}
}
$shippingAddress->setFirstname($row['firstname']);
$shippingAddress->setLastname($row['lastname']);
$shippingAddress->setCity($row['shipping_city']);
$shippingAddress->setRegion($row['shipping_region']);
if (isset($regionId)) {
$shippingAddress->setRegionId($regionId);
}
$shippingAddress->setCountryId($row['shipping_country']);
$shippingAddress->setPostcode($row['shipping_postcode']);
if (isset($row['shipping_street2'])) {
$shippingAddress->setStreet(array($row['shipping_street1'], $row['shipping_street2']));
} else {
$shippingAddress->setStreet(array($row['shipping_street1']));
}
if (!empty($row['shipping_telephone'])) {
$shippingAddress->setTelephone($row['shipping_telephone']);
}
if (!$shippingAddress->getId()) {
$shippingAddress->setIsDefaultShipping(true);
$this->addAddress($shippingAddress);
}
// End handling shipping address
}
if (!empty($row['is_subscribed'])) {
$this->setIsSubscribed(strtolower($row['is_subscribed']) == self::SUBSCRIBED_YES ? 1 : 0);
}
unset($row);
return $this;
}