本文整理汇总了PHP中Mage_Customer_Model_Address::setCustomerId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address::setCustomerId方法的具体用法?PHP Mage_Customer_Model_Address::setCustomerId怎么用?PHP Mage_Customer_Model_Address::setCustomerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Customer_Model_Address
的用法示例。
在下文中一共展示了Mage_Customer_Model_Address::setCustomerId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
//.........这里部分代码省略.........
$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();
}
}
$shippingAddress->setFirstname($row['firstname']);
$shippingAddress->setLastname($row['lastname']);
$shippingAddress->setCity($row['shipping_city']);
$shippingAddress->setRegion($row['shipping_region']);
$shippingAddress->setRegionId($regionId);
$shippingAddress->setCountryId($row['shipping_country']);
$shippingAddress->setPostcode($row['shipping_postcode']);
$shippingAddress->setStreet(array($row['shipping_street1'], $row['shipping_street2']));
$shippingAddress->setCustomerId($model->getId());
if (!empty($row['shipping_telephone'])) {
$shippingAddress->setTelephone($row['shipping_telephone']);
}
if (!$model->getDefaultShipping()) {
if ($customer->getDefaultShipping()) {
$model->setDefaultShipping($customer->getDefaultShipping());
} else {
$shippingAddress->save();
$model->setDefaultShipping($shippingAddress->getId());
$model->addAddress($shippingAddress);
}
$shippingAddress->setIsDefaultShipping(true);
}
if (!$rowError) {
$collection->addItem($model);
}
}
//foreach ($storeIds as $storeId)
} catch (Exception $e) {
if (!$e instanceof Mage_Dataflow_Model_Convert_Exception) {
$this->addException(Mage::helper('customer')->__("Error during retrieval of option value: %s", $e->getMessage()), Mage_Dataflow_Model_Convert_Exception::FATAL);
}
}
}
$this->setData($this->_collections);
return $this;
}
开发者ID:ankita-parashar,项目名称:magento,代码行数:101,代码来源:Intersec_Orderimportexport_Model_Convert_Parser_guest+orders_Exportorders.php