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


PHP Mage_Customer_Model_Customer::_beforeSave方法代码示例

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


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

示例1: _beforeSave

 protected function _beforeSave()
 {
     $oReq = Mage::app()->getFrontController()->getRequest();
     $data = $oReq->getPost('aitreg');
     if ($data && !Mage::registry('aitoc_customer_saved') && !Mage::registry('aitoc_customer_to_save')) {
         $oAttribute = Mage::getModel('aitcheckoutfields/aitcheckoutfields');
         foreach ($data as $sKey => $sVal) {
             $oAttribute->setCustomValue($sKey, $sVal, 'register');
         }
         Mage::register('aitoc_customer_to_save', true);
     }
     return parent::_beforeSave();
 }
开发者ID:finelinePG,项目名称:finelink-dev,代码行数:13,代码来源:FrontCustomerCustomer.php

示例2: _beforeSave

 protected function _beforeSave()
 {
     parent::_beforeSave();
     $storeId = $this->getStoreId();
     /**
     * ORIGINAL CODE
     *
      if (is_null($storeId)) {
         $this->setStoreId(Mage::app()->getStore()->getId());
     }
     */
     if (is_null($storeId) || !$storeId) {
         $this->setStoreId(Mage::app()->getStore(true)->getId());
     }
     $this->getGroupId();
     return $this;
 }
开发者ID:TrygveSkogsholm,项目名称:Magento-Patch,代码行数:17,代码来源:Customer.php

示例3: _beforeSave

 /**
  * Processing object before save data
  *
  * @return Mage_Customer_Model_Customer
  */
 protected function _beforeSave()
 {
     if (Mage::helper('fieldsmanager')->getStoredDatafor('enable')) {
         Mage::getSingleton('customer/session')->setRegistry('');
         $data = array();
         $fmedata = array();
         if (isset($_POST['fme_register'])) {
             $fmedata = $_POST['fme_register'];
         } elseif (isset($_POST['fme_account'])) {
             $fmedata = $_POST['fme_account'];
         }
         foreach ($fmedata as $key => $value) {
             if (substr($key, 0, 3) == 'fm_') {
                 $data[substr($key, 3)] = $value;
             }
         }
         if (is_array($data) and count($data) != 0) {
             Mage::getSingleton('customer/session')->setRegistry($data);
         }
     }
     return parent::_beforeSave();
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:27,代码来源:Customer.php

示例4: _beforeSave

 /**
  *
  * (override from an abstract parent)
  */
 protected function _beforeSave()
 {
     $oldId = $this->getId();
     if (!empty($oldId)) {
         $this->oldId = $oldId;
     }
     return parent::_beforeSave();
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:12,代码来源:Customer.php

示例5: _beforeSave

 protected function _beforeSave()
 {
     parent::_beforeSave();
     $checkUnique = array();
     $nameGroupAttribute = '';
     /**
      * Will detect which attributes are dates and files, and check unique attributes
      */
     $collection = Mage::getModel('customer/attribute')->getCollection();
     $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'eav_attribute');
     $collection->addFieldToFilter($alias . 'is_user_defined', 1);
     $collection->addFieldToFilter($alias . 'entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId());
     $castDate = array();
     $filesFields = array();
     $filesRestrictions = array();
     foreach ($collection as $attribute) {
         if ('selectgroup' == $attribute->getTypeInternal()) {
             $nameGroupAttribute = $attribute->getAttributeCode();
         }
         if ('datetime' == $attribute->getBackendType()) {
             $castDate[] = $attribute->getAttributeCode();
         }
         if ('file' == $attribute->getTypeInternal()) {
             $this->_fileAttributes[$attribute->getId()] = $attribute->getAttributeCode();
             $filesFields[] = $attribute->getAttributeCode();
             $filesRestrictions[$attribute->getAttributeCode()]['size'] = 1048576 * $attribute->getFileSize();
             $filesRestrictions[$attribute->getAttributeCode()]['type'] = $attribute->getFileTypes();
             $filesRestrictions[$attribute->getAttributeCode()]['dimentions'] = $attribute->getFileDimentions();
             $this->_savedFileNames[$attribute->getAttributeCode()] = $this->getData($attribute->getAttributeCode());
         }
         if ($attribute->getIsUnique()) {
             $translations = $attribute->getStoreLabels();
             if (isset($translations[Mage::app()->getStore()->getId()])) {
                 $attributeLabel = $translations[Mage::app()->getStore()->getId()];
             } else {
                 $attributeLabel = $attribute->getFrontend()->getLabel();
             }
             $checkUnique[$attribute->getAttributeCode()] = $attributeLabel;
         }
     }
     // Need to change `Customer Group Selector` attribute, if admin change group for customer in the Backend
     if ($nameGroupAttribute && ($backendPost = Mage::app()->getRequest()->getPost('account')) && isset($backendPost['group_id'])) {
         $entityType = Mage::getSingleton('eav/config')->getEntityType('customer');
         $groupAttribute = Mage::getModel('customer/attribute')->loadByCode($entityType, $nameGroupAttribute);
         $storeIds = explode(',', $groupAttribute->getData('store_ids'));
         if (in_array($this->getStoreId(), $storeIds) || in_array(0, $storeIds)) {
             $options = $groupAttribute->getSource()->getAllOptions(true, true);
             foreach ($options as $option) {
                 $temp = Mage::getModel('eav/entity_attribute_option')->load($option['value']);
                 if ($temp && $temp->getGroupId() && $temp->getGroupId() == $backendPost['group_id']) {
                     $this->setData($nameGroupAttribute, $option['value']);
                 }
             }
         }
     }
     /**
      * Adding customer attributes to self data array
      */
     $customerAttributes = Mage::app()->getRequest()->getPost('amcustomerattr');
     if (!$customerAttributes && ('checkout' == Mage::app()->getRequest()->getModuleName() || 'sgps' == Mage::app()->getRequest()->getModuleName() || 'amscheckoutfront' == Mage::app()->getRequest()->getModuleName())) {
         $customerAttributes = Mage::getSingleton('checkout/session')->getAmcustomerattr();
     }
     if ($customerAttributes) {
         // set to session attributes except file attributes
         if ($filesFields) {
             $temp = $customerAttributes;
             foreach ($customerAttributes as $attributeCode => $attributeValue) {
                 if (in_array($attributeCode, $filesFields)) {
                     unset($temp[$attributeCode]);
                 }
             }
             Mage::getSingleton('customer/session')->setAmcustomerattr($temp);
         } else {
             Mage::getSingleton('customer/session')->setAmcustomerattr($customerAttributes);
         }
         $deleteFiles = Mage::app()->getRequest()->getPost('amcustomerattr_delete');
         $idGroupSelect = 0;
         foreach ($customerAttributes as $attributeCode => $attributeValue) {
             if ($attributeCode == $nameGroupAttribute) {
                 $idGroupSelect = $attributeValue;
             }
             if (in_array($attributeCode, $castDate)) {
                 if ($attributeValue) {
                     $temp = Mage::app()->getLocale()->date($attributeValue);
                     $attributeValue = Mage::getModel('core/date')->date('Y-m-d', $temp->getTimestamp());
                 }
             }
             if (in_array($attributeCode, $filesFields)) {
                 if (isset($_FILES['amcustomerattr_' . $attributeCode]['error']) && UPLOAD_ERR_OK == $_FILES['amcustomerattr_' . $attributeCode]['error']) {
                     // check if uploaded new file
                     // correct filename
                     $temp = explode('.', $_FILES['amcustomerattr_' . $attributeCode]['name']);
                     $ext = strtolower(array_pop($temp));
                     $fileName = Mage::helper('amcustomerattr')->getCorrectFileName($temp[0]);
                     $f1 = Mage::helper('amcustomerattr')->getFolderName($fileName[0]);
                     $f2 = Mage::helper('amcustomerattr')->getFolderName($fileName[1]);
                     $fileDestination = Mage::getBaseDir('media') . DS . 'customer' . DS . $f1 . DS . $f2 . DS;
                     if (file_exists($fileDestination . $fileName . '.' . $ext)) {
                         // check if exist file with the same name
                         $attributeValue = DS . $f1 . DS . $f2 . DS . uniqid(date('ihs')) . $fileName . '.' . $ext;
//.........这里部分代码省略.........
开发者ID:guohuadeng,项目名称:stampApp,代码行数:101,代码来源:Customer.php

示例6: _beforeSave

 protected function _beforeSave()
 {
     parent::_beforeSave();
     $checkUnique = array();
     /**
      * Will detect which attributes are dates, and check unique attributes
      */
     $collection = Mage::getModel('customer/attribute')->getCollection();
     $collection->addFieldToFilter('is_user_defined', 1);
     $collection->addFieldToFilter('entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId());
     $castDate = array();
     foreach ($collection as $attribute) {
         if ('datetime' == $attribute->getBackendType()) {
             $castDate[] = $attribute->getAttributeCode();
         }
         if ($attribute->getIsUnique()) {
             $translations = $attribute->getStoreLabels();
             if (isset($translations[Mage::app()->getStore()->getId()])) {
                 $attributeLabel = $translations[Mage::app()->getStore()->getId()];
             } else {
                 $attributeLabel = $attribute->getFrontend()->getLabel();
             }
             $checkUnique[$attribute->getAttributeCode()] = $attributeLabel;
         }
     }
     /**
      * Adding customer attributes to self data array
      */
     $customerAttributes = Mage::app()->getRequest()->getPost('amcustomerattr');
     if (!$customerAttributes && ('checkout' == Mage::app()->getRequest()->getModuleName() || 'sgps' == Mage::app()->getRequest()->getModuleName())) {
         $customerAttributes = Mage::getSingleton('checkout/session')->getAmcustomerattr();
     }
     if ($customerAttributes) {
         Mage::getSingleton('customer/session')->setAmcustomerattr($customerAttributes);
         foreach ($customerAttributes as $attributeCode => $attributeValue) {
             if (in_array($attributeCode, $castDate)) {
                 $attributeValue = date('Y-m-d', strtotime($attributeValue));
             }
             $this->setData($attributeCode, $attributeValue);
         }
     }
     if ($checkUnique) {
         foreach ($checkUnique as $attributeCode => $attributeLabel) {
             //skip empty values
             if (!$this->getData($attributeCode)) {
                 continue;
             }
             $customerCollection = Mage::getResourceModel('customer/customer_collection');
             $customerCollection->addAttributeToFilter($attributeCode, array('eq' => $this->getData($attributeCode)));
             $mainAlias = false !== strpos($customerCollection->getSelect()->__toString(), 'AS `e') ? 'e' : 'main_table';
             $customerCollection->getSelect()->where($mainAlias . '.entity_id != ?', $this->getId());
             if ($customerCollection->getSize() > 0) {
                 $e = new Mage_Customer_Exception(Mage::helper('amcustomerattr')->__('Please specify different value for "%s" attribute. Customer with such value already exists.', $attributeLabel));
                 if (method_exists($e, 'setMessage')) {
                     $e->setMessage(Mage::helper('amcustomerattr')->__('Please specify different value for "%s" attribute. Customer with such value already exists.', $attributeLabel));
                 }
                 throw $e;
             }
         }
     }
     return $this;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:62,代码来源:Amasty_Customerattr_Model_Rewrite_Customer.php


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