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


PHP Mage_Customer_Model_Address::setId方法代码示例

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


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

示例1: 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


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