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


PHP Mage_Customer_Model_Customer::getAttribute方法代码示例

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


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

示例1: _addEditCustomerFormFields

 /**
  * Edit/View Existing Customer form fields
  *
  * @param Varien_Data_Form $form
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Mage_Customer_Model_Customer $customer
  */
 protected function _addEditCustomerFormFields($form, $fieldset, $customer)
 {
     $form->getElement('created_in')->setDisabled('disabled');
     if (!Mage::app()->isSingleStoreMode()) {
         $form->getElement('website_id')->setDisabled('disabled');
         $renderer = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Store_Switcher_Form_Renderer_Fieldset_Element');
         $form->getElement('website_id')->setRenderer($renderer);
     } else {
         $fieldset->removeField('website_id');
     }
     if ($customer->isReadonly()) {
         return;
     }
     $this->_addPasswordManagementFieldset($form, 'New Password', true);
     // Prepare customer confirmation control (only for existing customers)
     $confirmationKey = $customer->getConfirmation();
     if ($confirmationKey || $customer->isConfirmationRequired()) {
         $confirmationAttr = $customer->getAttribute('confirmation');
         if (!$confirmationKey) {
             $confirmationKey = $customer->getRandomConfirmationKey();
         }
         $element = $fieldset->addField('confirmation', 'select', array('name' => 'confirmation', 'label' => Mage::helper('Mage_Customer_Helper_Data')->__($confirmationAttr->getFrontendLabel())));
         $element->setEntityAttribute($confirmationAttr);
         $element->setValues(array('' => 'Confirmed', $confirmationKey => 'Not confirmed'));
         // Prepare send welcome email checkbox if customer is not confirmed
         // no need to add it, if website ID is empty
         if ($customer->getConfirmation() && $customer->getWebsiteId()) {
             $fieldset->addField('sendemail', 'checkbox', array('name' => 'sendemail', 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Send Welcome Email after Confirmation')));
             $customer->setData('sendemail', '1');
         }
     }
 }
开发者ID:nemphys,项目名称:magento2,代码行数:39,代码来源:Account.php

示例2: _prepareDataForUpdate

 /**
  * Prepare customer data for update
  *
  * @param array $rowData
  * @return array
  */
 protected function _prepareDataForUpdate(array $rowData)
 {
     /** @var $passwordAttribute Mage_Customer_Model_Attribute */
     $passwordAttribute = $this->_customerModel->getAttribute('password_hash');
     $passwordAttributeId = $passwordAttribute->getId();
     $passwordStorageTable = $passwordAttribute->getBackend()->getTable();
     $entitiesToCreate = array();
     $entitiesToUpdate = array();
     $attributesToSave = array();
     // entity table data
     $now = new DateTime('@' . time());
     if (empty($rowData['created_at'])) {
         $createdAt = $now;
     } else {
         $createdAt = new DateTime('@' . strtotime($rowData['created_at']));
     }
     $entityRow = array('group_id' => empty($rowData['group_id']) ? self::DEFAULT_GROUP_ID : $rowData['group_id'], 'store_id' => empty($rowData[self::COLUMN_STORE]) ? 0 : $this->_storeCodeToId[$rowData[self::COLUMN_STORE]], 'created_at' => $createdAt->format(Varien_Date::DATETIME_PHP_FORMAT), 'updated_at' => $now->format(Varien_Date::DATETIME_PHP_FORMAT));
     $emailInLowercase = strtolower($rowData[self::COLUMN_EMAIL]);
     if ($entityId = $this->_getCustomerId($emailInLowercase, $rowData[self::COLUMN_WEBSITE])) {
         // edit
         $entityRow['entity_id'] = $entityId;
         $entitiesToUpdate[] = $entityRow;
     } else {
         // create
         $entityId = $this->_getNextEntityId();
         $entityRow['entity_id'] = $entityId;
         $entityRow['entity_type_id'] = $this->getEntityTypeId();
         $entityRow['attribute_set_id'] = 0;
         $entityRow['website_id'] = $this->_websiteCodeToId[$rowData[self::COLUMN_WEBSITE]];
         $entityRow['email'] = $emailInLowercase;
         $entityRow['is_active'] = 1;
         $entitiesToCreate[] = $entityRow;
         $this->_newCustomers[$emailInLowercase][$rowData[self::COLUMN_WEBSITE]] = $entityId;
     }
     // attribute values
     foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) {
         if (!$this->_attributes[$attributeCode]['is_static'] && strlen($value)) {
             /** @var $attribute Mage_Customer_Model_Attribute */
             $attribute = $this->_customerModel->getAttribute($attributeCode);
             $backendModel = $attribute->getBackendModel();
             $attributeParameters = $this->_attributes[$attributeCode];
             if ('select' == $attributeParameters['type']) {
                 $value = $attributeParameters['options'][strtolower($value)];
             } elseif ('datetime' == $attributeParameters['type']) {
                 $value = new DateTime('@' . strtotime($value));
                 $value = $value->format(Varien_Date::DATETIME_PHP_FORMAT);
             } elseif ($backendModel) {
                 $attribute->getBackend()->beforeSave($this->_customerModel->setData($attributeCode, $value));
                 $value = $this->_customerModel->getData($attributeCode);
             }
             $attributesToSave[$attribute->getBackend()->getTable()][$entityId][$attributeParameters['id']] = $value;
             // restore 'backend_model' to avoid default setting
             $attribute->setBackendModel($backendModel);
         }
     }
     // password change/set
     if (isset($rowData['password']) && strlen($rowData['password'])) {
         $attributesToSave[$passwordStorageTable][$entityId][$passwordAttributeId] = $this->_customerModel->hashPassword($rowData['password']);
     }
     return array(self::ENTITIES_TO_CREATE_KEY => $entitiesToCreate, self::ENTITIES_TO_UPDATE_KEY => $entitiesToUpdate, self::ATTRIBUTES_TO_SAVE_KEY => $attributesToSave);
 }
开发者ID:,项目名称:,代码行数:67,代码来源:


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